I'm porting an application from MVC5/EF6 to MVC6/EF7, but having an issue with this particular line:
modelBuilder.Entity<Client>().HasMany(c => c.Payments).WithRequired(e => e.Client).WillCascadeOnDelete(false);
Apparently the WillCascadeOnDelete is transformed to the OnDelete with restrict as parameter, but I can't find any documentation on the "WithRequired" part which has disappeared too in EF7. Has 'WithOne' the same impact or am I completely wrong here :
modelBuilder.Entity<Client>().HasMany(c => c.Payments).WithOne(e => e.Client).OnDelete(Microsoft.EntityFrameworkCore.Metadata.DeleteBehavior.Restrict);
You are correct in both cases. Here is a detailed post... http://www.mikee.se/posts/migrating_from_ef6_to_ef_core
Typically these mappings would change from this in EF6.
x.Entity<Company>()
.HasMany(c => c.StatementOfEarnings)
.WithRequired(e => e.Company)
.WillCascadeOnDelete(false);
To this in EF Core
x.Entity<Company>()
.HasMany(c => c.StatementOfEarnings)
.WithOne(e => e.Company)
.OnDelete(DeleteBehavior.Restrict);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With