加入收藏 | 设为首页 | 会员中心 | 我要投稿 商洛站长网 (https://www.0914zz.com/)- AI应用、CDN、边缘计算、云计算、物联网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – ELMAH和SQL Server 2008 R2?

发布时间:2020-09-05 11:14:55 所属栏目:asp.Net 来源:互联网
导读:我尝试使用我的ASP.NET MVC 2项目运行 ELMAH但是有一些问题可以让它与我的SQL Server 2008 R2数据库一起使用. 这就是我所做的. 在我的数据库中运行dbscript,不小心我运行了两次,但在这种情况下似乎并不重要. 将以下部分添加到我的web.config(在configSection

我尝试使用我的ASP.NET MVC 2项目运行 ELMAH但是有一些问题可以让它与我的SQL Server 2008 R2数据库一起使用.

这就是我所做的.

>在我的数据库中运行dbscript,不小心我运行了两次,但在这种情况下似乎并不重要.
>将以下部分添加到我的web.config(在configSection下):

<elmah>
   <errorLog type="Elmah.SqlErrorLog,Elmah" connectionStringName="MyEntities" />
</elmah>

>这是我的Entity Framework连接字符串的样子:

<add name="MyEntities" 
     connectionString="metadata=res://*/Models.Model.MyEntities.csdl|res://*/Models.Model.MyEntities.ssdl|res://*/Models.Model.MyEntities.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=000.000.000.000;Initial Catalog=MyDatabase;Persist Security Info=True;User ID=[username];Password=[password];MultipleActiveResultSets=True&quot;" 
     providerName="System.Data.EntityClient" />

访问admin / elmah /页面时,我收到以下异常:

Keyword not supported: ‘metadata’. Description: An unhandled exception
occurred during the execution of the current web request. Please
review the stack trace for more information about the error and where
it originated in the code.

Exception Details: System.ArgumentException: Keyword not supported:
‘metadata’.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentException: Keyword not supported: ‘metadata’.]
System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable
parsetable,String connectionString,Boolean buildChain,Hashtable
synonyms,Boolean firstKey) +5110868
System.Data.Common.DbConnectionOptions..ctor(String connectionString,
Hashtable synonyms,Boolean uSEOdbcRules) +98
System.Data.SqlClient.SqlConnectionString..ctor(String
connectionString) +64
System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String
connectionString,DbConnectionOptions previous) +24
System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String
connectionString,DbConnectionPoolGroupOptions poolOptions,
DbConnectionOptions& userConnectionOptions) +150
System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value)
+59

我究竟做错了什么?

解决方法

实体框架连接字符串与sqlclient连接字符串不同,它们不兼容.您必须使用sqlclient连接字符串才能与elmah一起使用.
查看此站点以获取有效的连接字符串: http://connectionstrings.com/sql-server-2008

(编辑:商洛站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读