类型或“模型构建器”的命名空间无法找到(是否缺少using指令或程序集引用?) [英] Type or namespace of 'ModelBuilder' cannot be found (are you missing a using directive or assembly reference?)
本文介绍了类型或“模型构建器”的命名空间无法找到(是否缺少using指令或程序集引用?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在ASP.MVC 3教程的第7步,介绍了模型构建器类型。我使用ASP.Net 4,MVC 3,和EF 4.1,我也得到了模型构建器类型下的红色波浪线。它不能找到的类型。拥有这样的名字变了? ?我要补充什么参考使用它
使用系统;
使用System.Data.Entity的;
使用System.Data.Entity.ModelConfiguration;
...
保护覆盖无效OnModelCreating(模型构建器模型构建器)
{
modelBuilder.Entity<电影及GT;()房产(P =方式> p.Price ).HasPrecision(18,2);
}
解决方案
这个名字来源于CTP5来改变EF 4.1。这个东西现在被称为 DbModelBuilder
。
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);
}
解决方案
The name changed from CTP5 to EF 4.1. This thing is now called DbModelBuilder
.
这篇关于类型或“模型构建器”的命名空间无法找到(是否缺少using指令或程序集引用?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文