不能在类库项目中使用外部emdx [英] cannot use External emdx in class library project

查看:98
本文介绍了不能在类库项目中使用外部emdx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我在实现拥有edmx实体的类库时遇到了一些问题



i在我的解决方案2项目中:

1)控制台应用程序

2)类库(modelsLayer)



在类库中我使用向导创建了一个edmx实体



1)我添加到控制台应用程序引用modelsLayer。

2)通过dong浏览添加实体引用到modelsLayer的dll

(为了获得相同版本而不是从nuget添加实体框架)



3)并将连接部分从modelsLayer复制到控制台应用程序配置。



然后我得到了这个例外:



hello i have some problems to implementing class library that hold the edmx entity

i have in my solution 2 project :
1)console application
2) class library ("modelsLayer")

in the class library i created an edmx entity using wizard

1) i add to the console app reference to "modelsLayer".
2)add the entity reference by dong browse to the dll at the "modelsLayer"
(to get the same version instead add entity framework from nuget)

3)and copy the connection section from "modelsLayer" into the console application config.

and then i got this exception :

Model1.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file





这是类库应用程序。 config





This is the class library app.config


 <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="MyDbEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=LIOR-PC\SQLEXPRESS;initial catalog=MyDb;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>





我搜索任何答案结束检查仍然无法正常工作我





请帮助:(

推荐答案

我认为您使用的是旧版本。我设法通过在软件包管理器控制台上运行以下命令来修复它:



PM> Install-Package EntityFramework



如果命令不起作用,请下载NuGet Package Manager并使用此链接安装 NuGet包管理器



然后尝试它的工作。
I think you used old version. I managed to fix it by running the following command on Package Manager Console:

PM> Install-Package EntityFramework

And if comand not work then download NuGet Package Manager and install it using this link NuGet Package Manager

And then try it it's work.


这篇关于不能在类库项目中使用外部emdx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆