Tuesday May 31st

Monday May 30th

Sunday May 29th

Foreign key vs. Independent associations in Entity Framework 4

Independent and Foreign key associations are two ways to model relationships in Entity framework 4. This article describes differences between them.


I'm in the first camp. I think that foreign key relationships should be modeled in the contextual model because they are there for a reason. They represent a real-world relationship, and that relationship should carry through to your conceptual model. If this is not the case I would argue that "you're doing it wrong" ;-)

I'm sure there are exceptions to that, but I'm no stranger to database design and data-driven applications, and I've never created a foreign key that didn't have a purpose. Definitely not one that existed only to satisfy the database and be discarded elsewhere in my architecture.

Do you perhaps have an example you can share with us when it's preferable to ignore the fact that there's a foreign key association in the database? What do you do about error-handling in that case, and how is it preferable to catching the foreign key error raised by EF?

Thanks for the article!

The article is well written. It is a good read.

I am not sure why having two types of association can be a design flaw in Entity framework. Does it not give an option for the developers to choose one over another?

Commenting on Stories is limited for now and will open up to those recommended by the community. Learn how
Loading DotNetKicks...
brought to you by the Kicks Network