look at this question for example. Entity Framework (EF) Code First Cascade Delete for One-to-Zero-or-One relationship
I have a normal context etc.
If i change anything, i can generate a new migration per Add-Migration test
.
But if i change WillCascadeOnDelete() from true to false or adding some with true it is ignored by entity framework.
I'm using Code first with a generated model from database.
In the generated model everything was on WillCascadeOnDelete(false)
.
So now I'm changing it from false to true but its ignored by entity framework.
I tried this: http://msdn.microsoft.com/en-us/data/jj591620.aspx#CascadeDelete too.
After adding this lines ... Nothing changes if i add Add-Migration newTest
.
modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>()
modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>()
This is ignored, too, 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 works and would be appended in new Migrations...
The main class for this construct is the following.
[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 this tables:
- Some
- SomeToThing
- Thing
The SomeToThing
has additional variables and because that i can't map Some
directly to Thing
.