Closed amyboose closed 1 year ago
Note for triage: repros with SQL Server and on latest daily. Minimal repro below.
public class Program
{
public static void Main(params string[] args)
{
}
}
public abstract class Animal
{
public int Id { get; set; }
public string Name { get; set; }
}
public abstract class Pet : Animal
{
public string? Vet { get; set; }
public ICollection<Human> Humans { get; } = new List<Human>();
}
public class Cat : Pet
{
public string EducationLevel { get; set; }
}
public class Dog : Pet
{
public string FavoriteToy { get; set; }
}
public class Human : Animal
{
public Animal? FavoriteAnimal { get; set; }
public ICollection<Pet> Pets { get; } = new List<Pet>();
}
public class MyContext : DbContext
{
public DbSet<Animal> Animals => Set<Animal>();
public DbSet<Pet> Pets => Set<Pet>();
public DbSet<Cat> Cats => Set<Cat>();
public DbSet<Dog> Dogs => Set<Dog>();
public DbSet<Human> Humans => Set<Human>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Animal>().UseTpcMappingStrategy();
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder
.UseSqlServer(@"Data Source=(LocalDb)\MSSQLLocalDB;Database=AllTogetherNow")
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging();
}
}
I'm using a bit change example from microsoft documentation "What's new in EF 7":
Then I create 2 migrations using: 1) command "add-migration Init" 2) command "add-migration t2" (immediatly after first migration)
The second migration must be empty. But I've got non-empty result:
Provider and version information
EF Core version: 7.0.1 Database provider: Npgsql Entity Framework Core provider for PostgreSQL Target framework: NET 7.0 Operating system: Windows 10 IDE: Visual Studio 2022 17.4