asp.net - 不支持的关键字: 'metadata'。?在带有MVC3的 Entity Framework 中使用Sql连接

标签 asp.net asp.net-mvc asp.net-mvc-3 entity-framework entity-framework-4.3

我在我的Asp.Net MVC3应用程序中使用了Entity Framework 4。我的问题是我正在使用Entity Framework对数据库执行操作,效果很好。出于其他目的,我还使用Sql Connection从数据库存储和检索我的数据。我正进入(状态

[Keyword not supported: 'metadata']

与我的数据库连接时出错。

这是我的网络配置
  <add name="VibrantEntities" connectionString="metadata=res://*/Vibrant.csdl|res://*/Vibrant.ssdl|res://*/Vibrant.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=KAPS-PC\KAPSSERVER;initial catalog=vibrant;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

我正在使用类库,所以这是我的应用配置。
   <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=&quot;data source=KAPS-PC\KAPSSERVER;initial catalog=vibrant;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

最佳答案

ADO.NET的连接字符串(在本例中为SqlConnection)不采用这种格式。您正在使用一种特定于Entity Framework的工具。 ADO.NET应该是这样的:

"data source=KAPS-PC\KAPSSERVER;initial catalog=vibrant;integrated security=True"

因此,总而言之,您需要两个单独的连接字符串,一个用于EF,一个用于ADO.NET。

关于asp.net - 不支持的关键字: 'metadata'。?在带有MVC3的 Entity Framework 中使用Sql连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12946099/

相关文章:

asp.net-mvc - 如何使用 Ninject 将 ModelState 作为参数注入(inject)?

c# - 如何启用基于页面控件的禁用验证器?

c# - 当前对 Controller 类型 'Create' 的操作 'WeeklyTargetController' 的请求在以下操作方法 : 之间不明确

c# - 如何从 Controller 将数据传递到 View 中的jquery

c# - 验证摘要未显示 Controller 中生成的错误

javascript - 分页符页面的特定部分

.net - 多 View 控件如何处理其 View 状态?

c# - 为函数制作时间测量包装类的最佳方法是什么?

asp.net - 如何将 EC2 托管的 Shiny 应用程序安全地集成到 asp.net 项目中

entity-framework-4 - session 中的 ASP.Net MVC 存储用户实体