OwnedEntity why do I get DropForeignKey and CreateForeignKey for every new migration.
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
I have a owned entity but for every add-migration it creates a migration that has a DropForeignKey and CreateForeignKey because I added OnDelete without the OnDelete (or using the default DeleteBehavior.Cascade) it stops behaving like that. Is there any reason why or is this a bug.
public class OrderConfiguration : IEntityTypeConfiguration
{
public void Configure(EntityTypeBuilder builder)
{
builder.OwnsMany(x => x.OrderLines, orderLine =>
{
orderLine.HasOne(x => x.Order).WithMany(x => x.OrderLines)
.OnDelete(DeleteBehavior.ClientCascade); // <--- This triggers the migration to be generated every time.
});
}
}
.NET 6 EF Core 6.0.13
Contributor guide
Assessment
This issue has not been assessed yet.