When I create a new migration file after I change one property of an owned type object, the migration will delete all the columns, rename a few columns and add all the columns.
I get an error if I run the migration file. (error like: cannot drop column, because it doesn`t exist).
This happen now in a big project with some entity with a lot of owned types. It`s a little bit difficult to show all the code.
Here is a example of an entity.
public class TestTemplate : BaseEntity
{
public bool isActive { get; set; }
public TestTemplateContainer template { get; set; } = new TestTemplateContainer();
}
[Owned]
public class TestTemplateContainer
{
public TTGeneral general { get; set; } = new TTGeneral();
....
}
[Owned]
public class TTGeneral
{
public string model { get; set; } = "";
....
}
For example ,if I rename the model property in TTGeneral to new model, I expect only a rename of a column in the migration file. That`s not happen now.
ContextFile:
only the normal entity(the owner) has DBSet property.
In the OnModelCreating I only use the normal entity to table.
public class RecipeContext : DbContext
{
public class RecipeContext : DbContext
{
public RecipeContext(DbContextOptions<RecipeContext> options) : base(options) {
this.Database.SetCommandTimeout(300);
}
public DbSet<BasePreset> BasePreset { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<BasePreset>().ToTable("Preset");
...
}
}