The type or namespace "ModelBuilder" cannot be found (are you missing a directive or assembly reference?)

In step 7 of the ASP.MVC 3 tutorial , he introduces the ModelBuilder type. I use ASP.Net 4, MVC 3, and EF 4.1, and I get red squiggly lines under the ModelBuilder type. He cannot find the type. Is the name of this type changed? What link should be added to use it?

using System; using System.Data.Entity; using System.Data.Entity.ModelConfiguration; ... protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity<Movie>().Property(p => p.Price).HasPrecision(18, 2); } 
+8
c # asp.net-mvc entity-framework
source share
2 answers

The name has changed from CTP5 to EF 4.1. This thing is now called DbModelBuilder .

+23
source share

According to MSDN , which is still a good class. It is located in Microsoft.Data.Schema.SchemaModel .

I just experienced this and I had no problems. You need to make sure that you add the link in your project to the assembly indicated on the MSDN link. Build Microsoft.Data.Scheme.dll . Then in your code you need to use Microsoft.Data.Schema.SchemaModel .

+1
source share

All Articles