0

它告诉我连接字符串不正确,并且不支持“元数据”关键字。

连接字符串:在我生成模型时自动创建

<connectionStrings>
    <add name="DataContext"  connectionString="metadata=res://*/Models.Model.csdl|res://*/Models.Model.ssdl|res://*/Models.Model.msl;
      provider=System.Data.SqlClient;
      provider connection string='data source=.\SQLEXPRESS;
      initial catalog=&quot;Phase 2&quot;;
      integrated security=True;
      multipleactiveresultsets=True;
      application name=EntityFramework'" 
      providerName="System.Data.EntityClient" />
</connectionStrings>

角色管理器:将 connectionStringName 设置为上面的连接字符串的名称

<roleManager enabled="true">
  <providers>
    <clear />
    <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="DataContext" applicationName="/" />
  </providers>
</roleManager>

当我调用Roles.CreateRole方法时,它给了我以下错误

An error occurred while attempting to initialize a System.Data.SqlClient.SqlConnection     object. The value that was provided for the connection string may be wrong, or it may contain an invalid syntax.

内在例外

{"Keyword not supported: 'metadata'."}

有任何想法吗?

4

0 回答 0