SimpleMembershipProvider WebSecurity.InitializeDatabaseConnection使用空的sql数据库失败

MoX*_*lod 4 c# asp.net asp.net-membership asp.net-mvc-4 asp.net-4.5

我刚刚添加了一个sqlserver连接字符串.全新的数据库.我检查了服务器资源管理器上的连接是否正常.

<add name ="club" connectionString="Data Source=server1;Initial Catalog=temp;Integrated Security=True"/>
Run Code Online (Sandbox Code Playgroud)

然后在InitializeSimpleMembershipAttribute中引用它,如下所示

WebSecurity.InitializeDatabaseConnection("club", "Users", "UserID", "UserName", autoCreateTables: true);
Run Code Online (Sandbox Code Playgroud)

它在sdf文件中工作并创建表.但是使用sql server失败了.以前有人看过这个错误,可以解释发生了什么吗?

错误 -

不支持关键字:'初始目录'.异常详细信息:System.ArgumentException:不支持关键字:'initial catalog'.

Eri*_*sch 13

添加 providerName="System.Data.SqlClient"到您的连接字符串.

<add name="club" 
  connectionString="Data Source=server1;Initial Catalog=temp;Integrated Security=True"
  providerName="System.Data.SqlClient"/>
Run Code Online (Sandbox Code Playgroud)