GlobalConfiguration does not contain a definition for Configure

I am trying to create an ASP.NET MVC site that uses the underlying database infrastructure.

I use creating a new MVC 5 site in Visual Studio Professional 2013 Update 3 , then adding the ADO.NET Entity Data Model , from which I select EF Designer from the database .

After that, I create a connection string, select the tables to create the framework, and everything is fine.

However, when I compile it, I get this error

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

These are Global.asax.cs and errors here

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

GlobalConfiguration automatically created with the added frame structure for MyModel . It certainly does not have the 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; } } 

I followed all the answers here GlobalConfiguration.Configure () was not present after porting Web API 2 and .NET 4.5.1 , but no one worked. This is a slightly different situation, as this is not an update, but just a clean project.

All NuGet extensions and packages have been updated. I even deleted the generated object and reinstalled all the NuGet packages to make sure it helped, but no luck.

Any suggestions?

+5
source share
3 answers

There seems to be some sort of namespace conflict with the generated code. I'm pretty tired of this change, but everything still works.

Apparently GlobalConfiguration refers to MyModel.GlobalConfiguration .

However, he is really looking for System.Web.Http.GlobalConfiguration

I switched it and it works. 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); } 
+3
source
  • Open the Package Manager Console for the project with an error.
  • Type Install-Package Microsoft.AspNet.WebApi.WebHost and press Enter.
  • Restore your project.
+15
source

1 - make sure the files in Team Explorer, if you checkin;

2 - Check for old files in the "packages" in relation to the web dll folders, such as the "Microsoft.AspNet.WebApi.WebHost.5.2.3" folder, if there are any;

3 - After you leave everything, clean the project;

Good luck !!!!!

+1
source

Source: https://habr.com/ru/post/1200931/


All Articles