ZZZ Code AI
Report Issues
Suggest Features
Login
EF Core Tools
Chat
Code Explain
More Tools
How to change the name of the discriminator column when using a TPH inheritance in EF Core?
<p>You can choose the discriminator column name in the <code>OnModelCreating</code> by calling the <code>HasDiscriminator<string>([DiscriminatorColumnName])</code> method when mapping your entity type.</p> <p>Here is an example:</p> <pre><code class="language-csharp">protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity<Animal>() .HasDiscriminator<string>("DiscriminatorColumnName") .HasValue<Cat>("Cat") .HasValue<Dog>("Dog"); } </code></pre>
Sponsored by
Entity Framework Extensions
This field is required
A text with a minimum of 10 characters is required
Send
Legal & Licensing
Answer generated by AI may produce inaccurate information about code, people, facts, and more.
Advertising Break!
5
seconds left
Did you know...
That you can now sponsor this project on
GitHub
?