We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cross-posting this from ef core repo: dotnet/efcore#35604
Repro:
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; await using var ctx = new MyContext(); await ctx.Database.EnsureDeletedAsync(); await ctx.Database.EnsureCreatedAsync(); Console.WriteLine( "With instantiated DbContext:" ); foreach( var et in ctx.Model.GetEntityTypes() ) { var tn = et.GetTableName(); Console.WriteLine( $"{et.ClrType.Name} -> {tn}" ); } public class MyContext : DbContext { public DbSet<MyEntity> Entities { get; set; } protected override void OnModelCreating( ModelBuilder modelBuilder ) { modelBuilder.Entity<MyEntity>() .HasDiscriminator<string>( "entity_type" ) .HasValue<MyDerivedEntity1>( "1" ) .HasValue<MyDerivedEntity2>( "2" ); modelBuilder.Entity<MyEntity>() .ToTable( "entity_table" ); modelBuilder.Entity<MyDerivedEntity1>() .HasBaseType<MyEntity>(); modelBuilder.Entity<MyDerivedEntity2>() .HasBaseType<MyEntity>(); Console.WriteLine( "Within OnModelCreating:" ); foreach( IMutableEntityType mutableEntityType in modelBuilder.Model.GetEntityTypes() ) { var tableName = mutableEntityType.GetTableName(); Console.WriteLine( $"{mutableEntityType.ClrType.Name} -> {tableName}" ); } } protected override void OnConfiguring( DbContextOptionsBuilder optionsBuilder ) { optionsBuilder .UseSqlite( "DataSource=:memory:" ) .EnableSensitiveDataLogging() .UseSnakeCaseNamingConvention(); } } public abstract class MyEntity { public int Id { get; set; } public string Shared { get; set; } } public class MyDerivedEntity1 : MyEntity { public string Foo { get; set; } } public class MyDerivedEntity2 : MyEntity { public string Bar { get; set; } }
Output:
Within OnModelCreating: MyDerivedEntity1 -> entities MyDerivedEntity2 -> entities MyEntity -> entity_table Within OnModelCreating: MyDerivedEntity1 -> entities MyDerivedEntity2 -> entities MyEntity -> entity_table With instantiated DbContext: MyDerivedEntity1 -> entity_table MyDerivedEntity2 -> entity_table MyEntity -> entity_table
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Cross-posting this from ef core repo: dotnet/efcore#35604
Repro:
Output:
The text was updated successfully, but these errors were encountered: