views:

37

answers:

1

Is it not possible to have EF create the necessary entities when I have two related tables linked with a FK in .NET3.5SP1? I see where the checkbox to support this is disabled but it is available in .NET4.

I've got a DB that has only tables with relationships in it. I need to build a Silverlight app (SL4) that allows management of the data within this app. I can't use .NET4 on the server... only .NET3.5SP1 so FK relationship bit in EF4 isn't available to me. Looking to avoid building as much of the plumbing to get back to the DB from the SL4 app as possible...

+1  A: 

Do you use Visual Studio 2010 and target .NET Framework 3.5 in your project settings?

If that is the case, I guess with "disabled checkbox" you mean the checkbox to include foreign key columns in the wizard for creating an Entity Model from a database. (This checkbox doesn't exist at all in VS2008 and when targeting .NET 4.0 in VS2010 it isn't disabled. Hence my theory about VS2010 with .NET 3.5.)

So, then there are relatively good news for you: This checkbox does NOT mean that no Entity relationships would be created from tables linked by foreign key constraints. They WILL be created, also in Entity Framework 1 (.NET 3.5). You only won't have scalar Entity properties which represent your foreign key columns. (This checkbox - only available in .NET 4 -, being checked, will include those properties in the model.) Instead you always have to deal with the referenced objects in your entities (check, if they're loaded, load them manually or include them directly in queries, and so on).

So you have a bit less comfort when working with relationships in the Entity model in .NET 3.5 but the foreign key constraints are still represented correctly and automatically created. Just let the wizard run and explore the generated Entity model.

Slauma