1

I have added Cascade Delete to my database but I do not see this update in my model. How do I make sure that my model has cascade delete enabled for a database first model?

2
  • Sorry. I found it under the edmx model file. Dont know how I missed it. Commented Jul 20, 2011 at 16:04
  • Could you explain where you found this option as it's something I might need to do too? Commented Jul 20, 2011 at 16:07

1 Answer 1

2

If the cascade delete is set on the database then you have nothing to worry about. Deleting the main Object would translate on

  1. EF telling the DB "delete entity -foo-"
  2. DB checking all the dependencies for table -foo(s)-
  3. DB deleting first all records for -foo-.ID in all dependent tables
  4. DB finally deleting -foo-.ID in table -foo(s)-

It would be more cumbersome if you only had the cascade delete on the Model but not the Database, as that would mean the EntityFramework try to figure out all of the above on runtime.

If you really want to ensure the cascade delete, you could enable it in both layers, although it doesn't sound like a good idea to me as some data "might disappear" (because it was cascade deleted) from the EF state manager.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.