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