Foreign key vs. Independent associations in Entity Framework 4

added by LadislavMrnka
9/2/2011 8:57:19 AM

4 Kicks, 288 Views

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


9/2/2011 9:02:13 AM
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!

9/3/2011 9:14:31 AM
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?