0

If I have an object that has a foreign key to and I delete this object will it delete the object associated to it by the foreign key? (I always thought the answer was no).

I am using entity framework and I am setting up a bunch of 1 to many relations for items.

Ie Company has many orders. Orders would have a foreign key to Company. Deleting an order would not delete the corresponding Company correct? But Deleting the Company would delete the corresponding orders?

I know this is really an easy one but some internet postings have gotten me confused.

DanScan
  • 831
  • 2
  • 10
  • 23
  • Cascading generally [only?] goes Parent->Child. Perhaps http://stackoverflow.com/questions/5448702/cascading-deletes-with-entity-framework-related-entities-deleted-by-ef might be relevant. – user2246674 Sep 20 '13 at 21:15

1 Answers1

0

Yes and no, When you delete a company you can do 2 things, remove the CompanyID of the Order or as you say delete the order. By Default it will just delete the Orders.

Luis Tellez
  • 2,785
  • 1
  • 20
  • 28