Leveraging VS2010’s Entity Data Model Designer for .NET 3.5 Projects

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:

image

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.

 image

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.

image

image

Here is that complex type in an entity that was retrieved from the database.

image

Model First works too:

image

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.

image

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:

image

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.

image

(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.

#1 BigJim on 1.19.2010 at 1:00 PM

Hi, how about something for us new folks that describes what kind of setup / installs you need to do in order to use EF 4 in .Net 3.5?

Thanks! Got the book, and am loving it!

#2 Julie on 1.19.2010 at 1:37 PM

Hey Jim, sorry but you need .NET 4 to use EF4 features.

#3 BigJim on 1.19.2010 at 2:38 PM

That's what I thought - I have both the 2010 beta and regular 2008. I must have misread, I thought the post was about how to use EF4 in .Net 3.5. I see now that you're talking about using .Net 4 to target .Net 3.5 runtime, but not about using anything special in VS2008/.Net 3.5.

Thanks again!

Leave a Comment