【问题标题】:Use SQL Server database for code first migrations in ASP.NET MVC 4在 ASP.NET MVC 4 中使用 SQL Server 数据库进行代码优先迁移
【发布时间】:2013-07-04 00:18:56
【问题描述】:

我一直在尝试使用带有代码优先迁移的 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."

如果有任何帮助,我将不胜感激。

【问题讨论】:

    标签: asp.net-mvc-4 visual-studio-2012 entity-framework-5 entity-framework-migrations sql-server-2012-express


    【解决方案1】:

    确认!我什至没有意识到 providerName 将被指定为单独的键值!

    【讨论】:

      猜你喜欢
      • 2014-05-23
      • 1970-01-01
      • 2016-11-24
      • 2014-05-28
      • 1970-01-01
      • 1970-01-01
      • 2021-03-26
      • 2018-02-24
      • 1970-01-01
      相关资源
      最近更新 更多