look at this question for example. Entity Framework (EF) code The first cascade search for a one-on-one or one relationship
I have a normal context, etc.
If I change something, I can create a new migration in the Add-Migration test .
But if I change the value of WillCascadeOnDelete () from true to false or adding some with true, it is ignored by the entity framework.
I use Code first with the model created from the database. In the generated model, everything was on WillCascadeOnDelete(false) . So, now I change it from false to true, but the entity structure ignores it.
I tried this: http://msdn.microsoft.com/en-us/data/jj591620.aspx#CascadeDelete too.
After adding these lines ... Nothing will change if I add Add-Migration newTest .
modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>() modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>()
This is also ignored by Add-Migration thirdTest .
modelBuilder.Conventions.Add<OneToManyCascadeDeleteConvention>() modelBuilder.Conventions.Add<ManyToManyCascadeDeleteConvention>()
I can change everything with WillCascadeOnDelete ... It is ignored!
If I change everything else, it will work and be added to the new Migrations ...
The main class for this construction is as follows.
[Table("SomeToThing")] public class SomeToThing : Base { [Column("Some")] public Guid SomeId { get; set; } [ForeignKey("SomeId")] public virtual Some Some { get; set; } [Column("Thing")] public Guid ThingId { get; set; } [ForeignKey("ThingId")] public virtual Thing Thing { get; set; } }
I have the following tables:
SomeToThing has additional variables because I cannot match Some directly with Thing .