1

I'd like the migration to set false, not true, to deletion cascading, when automatically generated.

AddForeignKey("dbo.Stuff", "Id", "dbo.Things", "Id", cascadeDelete: false);

Is it the only way to put something in the model creation?

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
  modelBuilder
    .Entity<Stuff>()
    .WillCascadeOnDelete(true);
}
Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
  • http://stackoverflow.com/questions/5569072/can-i-use-data-annotations-to-perform-a-cascade-delete-with-entity-framework-4-1 – Steve Greene Jan 11 '16 at 20:09
  • @SteveGreene In the link, they show how to **cause** the cascading to be *true*. I have the opposite request - I want it to be *false*. I wish the field to be required (creating *not null*) but not cascade deleteable. – Konrad Viltersten Jan 11 '16 at 20:15
  • Sorry, your .WillCascadeOnDelete(true); threw me off. Have you tried disabling the convention? http://stackoverflow.com/questions/13705441/how-to-disable-cascade-delete-for-link-tables-in-ef-code-first – Steve Greene Jan 11 '16 at 20:21
  • @SteveGreene Perhaps I asked the question in an unclear way. I already know how to get what I want **but** I prefer to do that using **attributes** instead of **fluid API**. So the second code sample (using *modelBuilder*) is **the opposite** of the approach I'm looking for **but** at the same time it's **the same** effect that I want to create. I want to see if it's possible to go *[SomeSome]* and get it to work. Perhaps it's not possible, period? – Konrad Viltersten Jan 11 '16 at 20:25

0 Answers0