在项目之间共享实体框架对象? [英] Sharing Entity framework objects across projects?

查看:144
本文介绍了在项目之间共享实体框架对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些重构的麻烦,也许有人知道为什么...

I am having some refactor troubles, maybe someone knows why...

在一个解决方案中,我有一个WCF服务。在另一个解决方案我有一个RIA应用程序。由于这两者之间的SQL数据库是完全相同的,所以我想创建一个独立的项目,用于托管edmx文件以及域服务。如果我直接在WCF项目中创建edmx文件,并且在RIA端执行相同的操作,一切都可以正常工作。

In one solution I have a WCF service. In another solution I have a RIA application. Since the SQL database between these two is identical, I wanted to create a separate project, in which to host the edmx file as well as a domain service. If I create the edmx file in the WCF project directly, and do the same on the RIA side, everything works fine.

但是当我尝试将此edmx文件一个单独的项目,并添加引用我得到各种奇怪的错误,我的实体对象找不到。 WCF服务本身似乎很好,因为它引用了edmx项目并编译得很好。

But when I try to pull this edmx file into a separate project and add references to it I get all kinds of bizarre errors that my entity objects cannot be found. The WCF service itself seems fine, in that it references the edmx project and compiles just fine.

但是,具有对WCF服务的服务引用的WCF客户端项目会引用实体引用。即使添加edmx程序集也没有真正的帮助 - 一些实体被发现其他的不是。非常奇怪

But the WCF client project, that has a service reference to the WCF service pukes on the entity references. Even adding the edmx assembly doesnt really help- some entities are found others are not. Very odd.

任何人都知道我失踪了什么?

Anyone know what Im missing?

推荐答案

您尝试使用该模型的所有项目中的连接字符串。
但是,在连接字符串中,删除OR'd资源指针。

Copy the connection string across all your projects which attempt to use the model. However, in the connection string, remove the OR'd Resource pointers.

完整实体连接

<connectionStrings>

    <add name="AwesomeEntityModel" 
         connectionString="metadata=res://*/AwesomeEntityModel.csdl|res://*/AwesomeEntityModel.ssdl|res://*/AwesomeEntityModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\sqlexpress;initial catalog=NEILHIGHLEY.COM;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" 
         providerName="System.Data.EntityClient" />
</connectionStrings>

修改如下:

<connectionStrings>
    <add name="AwesomeEntityModel" 
         connectionString="metadata=res://*;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\sqlexpress;initial catalog=NEILHIGHLEY.COM;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" 
         providerName="System.Data.EntityClient" />
</connectionStrings>

这篇关于在项目之间共享实体框架对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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