问题描述
这行:
WebSecurity.InitializeDatabaseConnection(connectionStringName: "DefaultConnection", userTableName: "UserProfile", userIdColumn: "UserID", userNameColumn: "UserName", autoCreateTables: true);
时抛出:
System.ArgumentException出现在system.data.dll但在用户code没有处理
'System.ArgumentException' occurred in System.Data.dll but was not handled in user code
其他信息:不支持关键字:元数据
Additional information: Keyword not supported: 'metadata'.
我的连接字符串是:
add name="DefaultConnection" connectionString="metadata=res://*/TalyllynModel.csdl|res://*/TalyllynModel.ssdl|res://*/TalyllynModel.msl;provider=System.Data.SqlClient;provider connection string="data source=***********;initial catalog=********;persist security info=True;user id=*********;password=********;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.SqlClient" /></connectionStrings>
不知道在那里我去错了。
Not sure where it is im going wrong.
推荐答案
您传递的字符串不是有效的数据库连接字符串,它是一个的包含其提供商连接字符串
参数在SQL Server连接字符串。 WebSecurity.InitializeDatabaseConnection需要一个有效的数据库连接字符串
The string you passed is not a valid database connection string, it's an EF connection string that contains a SQL Server connection string in its provider connection string
parameter. WebSecurity.InitializeDatabaseConnection expects a valid database connection string
要避免自己解析连接字符串,则可以使用类来分析串并检索其ProviderConnectionString财产
To avoid parsing the connection string yourself, you can use the EntityConnectionStringBuilder class to parse the string and retrieve the database connection string from its ProviderConnectionString property
这篇关于关键字不支持:元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!