问题描述
我使用实体框架4与我的Asp.Net MVC3的应用程序。我的问题是,我使用实体框架和我的数据库执行操作,这是工作的罚款。对于一些其他的目的,我也使用SQL连接到存储和数据库中取出我的数据。我正在
[不支持关键字:'元']
错误,而我的数据库连接。
这是我的web配置
<添加名称=VibrantEntities connectionString=\"metadata=res://*/Vibrant.csdl|res://*/Vibrant.ssdl|res://*/Vibrant.msl;provider=System.Data.SqlClient;provider连接字符串=安培; QUOT;数据源= KAPS-PC \\ KAPSSERVER;初始目录=活力;集成安全=真; multipleactiveresultsets = TRUE;应用=&的EntityFramework放大器; QUOT;的providerName =System.Data.EntityClient/>
我使用的类库,所以这是我的应用程序配置。
<节名称=的EntityFrameworkTYPE =System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,的EntityFramework,版本= 4.3.0.0,文化=中性公钥= b77a5c561934e089 /> <添加名称=VibrantEntities connectionString=\"metadata=res://*/Vibrant.csdl|res://*/Vibrant.ssdl|res://*/Vibrant.msl;provider=System.Data.SqlClient;provider连接字符串=安培; QUOT;数据源= KAPS-PC \\ KAPSSERVER;初始目录=活力;集成安全=真; multipleactiveresultsets = TRUE;应用=&的EntityFramework放大器; QUOT;的providerName =System.Data.EntityClient/>
有关ADO.NET连接字符串(在这种情况下,的SqlConnection
)不采取这一格式。您使用的是一个特定的实体框架。 ADO.NET的应该是这样的:
数据源= KAPS-PC \\ KAPSSERVER;初始目录=活力;集成安全=真
所以,总结起来,你需要两个单独的连接字符串,一个用于EF和一个ADO.NET
I am using Entity Framework 4 with my Asp.Net MVC3 application. My problem is that I am using Entity Framework to perform action with my database , That is working fine. For some other purpose I am also using Sql Connection to Store and Retrieve my data from database. I am getting
[Keyword not supported: 'metadata']
error while connecting with my database.
This is my web config
<add name="VibrantEntities" connectionString="metadata=res://*/Vibrant.csdl|res://*/Vibrant.ssdl|res://*/Vibrant.msl;provider=System.Data.SqlClient;provider connection string="data source=KAPS-PC\KAPSSERVER;initial catalog=vibrant;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
I am using class Library, So this is my App Config.
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add name="VibrantEntities" connectionString="metadata=res://*/Vibrant.csdl|res://*/Vibrant.ssdl|res://*/Vibrant.msl;provider=System.Data.SqlClient;provider connection string="data source=KAPS-PC\KAPSSERVER;initial catalog=vibrant;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
The connection string for ADO.NET (in this case SqlConnection
) doesn't take that format. You're using the one specific for Entity Framework. The ADO.NET one should be something like:
"data source=KAPS-PC\KAPSSERVER;initial catalog=vibrant;integrated security=True"
So, to sum it up, you need two separate connection strings, one for EF and one for ADO.NET
这篇关于关键字不支持:“元数据”?在Entityt框架与MVC3 SQL连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!