Asp.net mvc 4 在ASP.NET MVC 4中使用SQL Server数据库进行代码优先迁移

Asp.net mvc 4 在ASP.NET MVC 4中使用SQL Server数据库进行代码优先迁移,asp.net-mvc-4,visual-studio-2012,entity-framework-5,entity-framework-migrations,sql-server-2012-express,Asp.net Mvc 4,Visual Studio 2012,Entity Framework 5,Entity Framework Migrations,Sql Server 2012 Express,我一直在尝试使用SQL Server数据库进行代码优先迁移。对于我最近的尝试,我: 创建了一个新的ASP.NET MVC 4 Web应用程序项目(是的,我想使用此模板) 创建模型实体 创建了从dbcontext继承的数据上下文类 在应用程序根目录中的Web.config中放置了以下连接字符串: add name="DefaultConnection" connectionString="Data Source=.\sqlexpress;Integrated Security=true;Ini

我一直在尝试使用SQL Server数据库进行代码优先迁移。对于我最近的尝试,我:

  • 创建了一个新的ASP.NET MVC 4 Web应用程序项目(是的,我想使用此模板)
  • 创建模型实体
  • 创建了从dbcontext继承的数据上下文类
  • 在应用程序根目录中的Web.config中放置了以下连接字符串:

     add name="DefaultConnection" connectionString="Data Source=.\sqlexpress;Integrated Security=true;Initial Catalog=DatingAnAsianWoman;MultipleActiveResultSets=true;providerName=System.Data.SqlClient"
    
  • 在包管理器中,我输入:

    Enable-Migrations -ContextTypeName UsersContext
    
  • 其次是:

    Update-Database
    
此时,我收到以下错误:

The connection string 'DefaultConnection' in the application's configuration file does not contain the required providerName attribute."

我将非常感谢您的帮助。

谢谢!我甚至没有意识到providerName将被指定为一个单独的键值