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.

  Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!  

6 thoughts on “Leveraging VS2010’s Entity Data Model Designer for .NET 3.5 Projects

  1. 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. 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!

  3. Hi,

    The Model First (Code Only) suffer from lack documentation and examples, Where I can find a "Real" Documentation ?

  4. Hello Julie,

    Thank you for this great article. Sometimes we cannot just go there and update the target framework, since final customer will have install it also. (what might be cumbersome).

    The great thing that you highlighted is that the edmx designer capabilites in VS has nothing to do with the target framwork.

    We are using EF to target SQL Compact and we are having great results !!

Leave a Reply to Boaz Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.