Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GlobalConfiguration does not contain a definition for Configure

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

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' does not contain a definition for 'Configure'

This is in 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 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; }
}

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.

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.

Any suggestions?

like image 873
Kirk Avatar asked Aug 22 '14 15:08

Kirk


1 Answers

  1. Open the Package Manager Console for the Project with the error.
  2. Type in Install-Package Microsoft.AspNet.WebApi.WebHost and hit Enter.
  3. Rebuild your Project.
like image 187
Jason Williams Avatar answered Sep 19 '22 18:09

Jason Williams