2

I am trying to use the EntityFramework with mvc 3 in VS. I have installed the EntityFramework under references but when I attempt to use the framework in the line

using System.Data.Entity.ModelConfiguration.Conventions.Edm.db;

I receive an red error under .edm saying

The namespace or name 'Edm' does not exist in the namespace 'System.Data.Entity.ModelConfiguration.Conventions' (are you missing an assembly reference?)

Orginally I thought I had an old version of the EntityFramework, so I unistalled the package and reinstalled the newest version but I still receive the same error.

Is there another package I need to install?

2
  • Check the target framework of your MVC project. I had an issue before where Visual Studio defaults the target framework to .NET 4 Framework (Client Profile) instead of .NET 4 Framework Commented Apr 21, 2011 at 19:12
  • Thanks, but the target framework is set the .NET 4 Framework Commented Apr 21, 2011 at 19:28

2 Answers 2

2

You may find this new MVC 3 / EF tutorial series helpful: http://www.asp.net/entity-framework/tutorials/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application It is based on Code First and the latest Tools Update for MVC 3.

Sign up to request clarification or add additional context in comments.

Comments

1

The namespace System.Data.Entity.ModelConfiguration.Conventions.Edm existed in the older version of Entity Framework CTP5. It has been removed in EF 4.1 RTW (which is the newest version you have installed now).

It's likely that you using some older project or demo which was based on CTP5. Migration to EF 4.1 is usually fairly easy; the features are mostly still there, perhaps under other namespaces or renamed a bit.

4 Comments

Thanks, that makes sense. but if I attempting to use the method 'code' protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); }' which namespace under the EF4.1 would reference?
@Bryan: What about checking documentation? Have you heard about MSDN Library? msdn.microsoft.com/en-us/library/gg696316%28v=VS.103%29.aspx
Thanks, that was a lot of help. With the new 4.1 are the entities still accessed as plural?
@Bryan: 1) Rename ModelBuilder to DbModelBuilder (class name has changed in EF 4.1), 2) using System.Data.Entity; for DbModelBuilder, 3) using System.Data.Entity.ModelConfiguration.Conventions; for PluralizingTableNameConvention, 4) and yes, Ladislav's link is a good one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.