-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Non-empty second migration in TPC scheme using inheritance #30058
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Milestone
Comments
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();
}
} |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
I'm using a bit change example from microsoft documentation "What's new in EF 7":
Then I create 2 migrations using:
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
The text was updated successfully, but these errors were encountered: