ModelBuilder's type or namespace could not be found (maybe you have a missing using directive or assembly reference?)

asp.net-mvc c# entity-framework

Question

In step 7 of the ASP.MVC 3 Tutorial, it introduces the 'ModelBuilder' type. I'm using ASP.Net 4, MVC 3, and EF 4.1, and I get the red squiggly lines under the 'ModelBuilder' type. It can't find the type. Has that type name changed? What reference should I add 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);
    }
1
8
3/27/2011 4:17:01 PM

Accepted Answer

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

25
3/27/2011 6:23:44 PM

Popular Answer

According to MSDN that is still a good class. It's located in Microsoft.Data.Schema.SchemaModel.

I just tested this and I had no problems. You need to make sure you add a reference in your project to the the assembly listed at the MSDN link. The assembly is Microsoft.Data.Scheme.dll. Then in your code you need a using Microsoft.Data.Schema.SchemaModel.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow