One of the benefits of Visual Studio’s multi-targeting is that if you are still stuck using the .NET 3.5 version of Entity Framework and are unable to move to EF4 (so sad), you can still get the new designer goodies for a .NET 3.5 project. Remember that the designer is a VS2010 feature, not a .NET 4.0 feature.
Be sure to select .NET 3.5 when you create your project:
When you add the model, you’ll notice that the foreign key checkbox is disabled. FK support is not only an EF4 designer feature but it is dependent on .NET 4. But you can still get the much needed pluralization support.
Once the model is created, you can take advantage of new designer features such as the complex type support. Complex tyeps existed in .NET 3.5 but the designer did not support them making it painful to take advantage of them.
Here is that complex type in an entity that was retrieved from the database.
Model First works too:
Not every new designer feature will work with an older model though.
T4 code generation won’t. You can select “Create Code Generation Item” from the context menu, but no templates will be available.
EF 3.5 uses a different type of code generation.
Function Import will NOT provide the nifty EF4 support for mapping stored procedure results to Complex Types:
Without the Foreign Key support, the model will use what’s called “Independent Associations” in other words, the same type of associations that we were limited to in .NET 3.5 where the association was dependent on the mappings.
Even though the designer has a referential constraint in the properties window, you can’t build it with this model because the foreign key is not available.
(With an EF4 model, you can use either Independent Associations or Foreign Key Associations.)
So if you are stuck building EF v3.5 apps (oh please please move to EF4, life will be SO much happier!), you can still get a lot of benefit from using VS2010’s designer.
Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!