gpt4 book ai didi

asp.net-mvc - GlobalConfiguration 不包含配置的定义

转载 作者:行者123 更新时间:2023-12-01 23:30:09 26 4
gpt4 key购买 nike

我正在尝试创建一个使用数据库优先 Entity Framework 的 ASP.NET MVC 站点。

我正在 Visual Studio Professional 2013 Update 3 中创建一个新的 MVC 5 网站,然后添加一个 ADO.NET 实体数据模型,我从中选择>来自数据库的 EF 设计器

之后,我创建一个连接字符串,选择表来生成框架,一切顺利。

但是当我编译它时,我收到此错误

'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 添加的 Entity Framework 自动生成的。它当然没有配置方法。

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

我遵循了这里的所有答案GlobalConfiguration.Configure() not present after Web API 2 and .NET 4.5.1 migration但没有一个起作用。这是一个略有不同的情况,因为这不是升级,而是一个干净的项目。

所有扩展和 NuGet 包都是最新的。我什至删除了生成的实体并重新安装了所有 NuGet 包以查看是否有帮助,但没有运气。

有什么建议吗?

最佳答案

  1. 打开出现错误的项目的Package Manager Console
  2. 输入Install-Package Microsoft.AspNet.WebApi.WebHost 并按 Enter 键。
  3. 重建您的项目。

关于asp.net-mvc - GlobalConfiguration 不包含配置的定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25450105/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com