GlobalConfiguration不包含配置定义 [英] GlobalConfiguration does not contain a definition for Configure

查看:1274
本文介绍了GlobalConfiguration不包含配置定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个使用数据库一是实体框架的ASP.NET MVC的网站。

I'm attempting to create an ASP.NET MVC site that uses Database First Entity Framework.

我使用的是创建一个新的MVC 5个网站中的的Visual Studio 2013专业版更新3 ,然后添加 ADO.NET实体数据模型我从中选择从数据库EF设计师

I'm using creating a new MVC 5 site in Visual Studio Professional 2013 Update 3, then adding an ADO.NET Entity Data Model from which I choose EF Designer from database.

在这之后,我创建了一个连接字符串,请选择该表生成框架,一切都很好。

After that, I create a connection string, select the tables to generate the framework, and all is well.

然而,当我编译它,我收到此错误

However when I compile it, I receive this error

MyModel.GlobalConfiguration'不包含一个定义
  配置

'MyModel.GlobalConfiguration' does not contain a definition for 'Configure'

这是在的Global.asax.cs 并在这里误差

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();
    GlobalConfiguration.Configure(WebApiConfig.Register);
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    BundleConfig.RegisterBundles(BundleTable.Bundles);
}

GlobalConfiguration 将自动为为MyModel 添加的实体框架生成的。这当然没有一个配置方法。

GlobalConfiguration is automatically generated with the added entity framework for MyModel. It certainly doesn't have a Configure method.

public partial class GlobalConfiguration
{
    public int ID { get; set; }
    public long CurrentUSN { get; set; }
    public string DBVersion { get; set; }
    public long CurrentFile { get; set; }
}

我跟所有的答案在这里<一个href=\"http://stackoverflow.com/questions/20226715/globalconfiguration-configure-not-$p$psent-after-web-api-2-and-net-4-5-1-migra\">GlobalConfiguration.Configure()非Web API 2和.NET 4.5.1迁移但没有经过present工作。这是一个略有不同的情况,因为这不是升级,而是代替清洁工程。

I followed all of the answers here GlobalConfiguration.Configure() not present after Web API 2 and .NET 4.5.1 migration but none worked. It's a slightly different situation as this isn't an upgrade but is instead a clean project.

所有的扩展和的NuGet包是最新的。我甚至删除生成的实体,并重新安装所有的Nu​​Get包,看看是否能帮助,但没有运气。

All Extensions and NuGet packages are up to date. I've even deleted the generated entity and reinstalled all NuGet packages to see if that helped, but no luck.

有什么建议?

推荐答案

它看起来像有某种与生成code的命名空间冲突。我相当疲惫的这个变化,但迄今为止一切都已经工作。

It looks like there is some sort of namespace conflict with the generated code. I'm fairly weary about this change, but everything has worked thus far.

显然 GlobalConfiguration MyModel.GlobalConfiguration

不过它真的找 System.Web.Http.GlobalConfiguration

我转这和所有工作。什么麻烦

I switched this and all is working. What a hassle

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();
    System.Web.Http.GlobalConfiguration.Configure(WebApiConfig.Register);
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    BundleConfig.RegisterBundles(BundleTable.Bundles);
}

这篇关于GlobalConfiguration不包含配置定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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