不能找到“ModelBuilder”的类型或命名空间(您是否缺少using指令或程序集引用?) [英] Type or namespace of 'ModelBuilder' cannot be found (are you missing a using directive or assembly reference?)

查看:415
本文介绍了不能找到“ModelBuilder”的类型或命名空间(您是否缺少using指令或程序集引用?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ASP.MVC 3教程第7步,它引入了ModelBuilder类型。我正在使用ASP.Net 4,MVC 3和EF 4.1,并且我得到ModelBuilder类型下的红色波浪线。它找不到类型。该类型名称是否已更改?我应该添加什么引用来使用它?

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);
    }


推荐答案

名称从CTP5更改为EF 4.1。这个东西现在称为 DbModelBuilder

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

这篇关于不能找到“ModelBuilder”的类型或命名空间(您是否缺少using指令或程序集引用?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆