Enity Framework: Unable To Delete Entity Because Primary End Of Foreign Key Constraint Has Been Deleted

I got this error even though the Foreign Key constraint had been deleted from the database and I had re-executed all my EF Template files, had refreshed my Model from the database and had deleted the relevant Navigation propertry from my Model.

Thing is , I had forgotten to physically delete the Association in the Model Designer .edmx file. When I did that and then re-ran my Model Template file all was well.

So I reckon I had only refreshed the secondary (referencing) table in the FK side. Next time I will refresh the primary (referenced) table as well.

That’s all. Get back to what you were doing. The door is the wooden thing in the wall behind you.


Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: