0

Just learning EF, coming from a different ORM tool. I am looking for these delete options. I can't find them so do they exist? Or how are they done in EF?

On Delete: I am familiar with 4 options on a relationship when an object is deleted. I only see one in EF as of now:

  1. Cascasde (EF has this I see, great)
  2. Deny/Throw (ORM I have used handles this by throwing an exception if you try to delete an object hat has related records for the given relatuionship )

    Example: Customer -> Orders (If I try to delete a Customer with related Orders the Delete is denied)

  3. Set Null (ORM I have used handles this by automatically setting the FK to null in the related table)

  4. None (EF has this I see, great) - No Action

    Example: DepartmentSupervisor(Employee) <- Department (If you delete the Employee the DepartmentSupervisor FK in the Department table is set to null)

JAMES
  • 27
  • 4

1 Answers1

0

EF does not support check constraints, you need to define check constrains at the table level using SSMS. Right click on the table, choose 'Design' then right-click again and choose 'Check Constraints' you'll be able to define any 'On Delete Rules' there...

Dean Kuga
  • 11,878
  • 8
  • 54
  • 108
  • Allready did that, thanks, I was hoping EF would do what i am familiar with and catch it before it goes round trip to the database. – JAMES Jan 24 '13 at 17:33