简体   繁体   English

拆分EDM以在多个项目中复用功能

[英]Splitting up EDM to reuse functionality across multiple projects

I currently have an ASP .NET MVC / EF4 project that contains many pieces of autonomous functionality such as a blogging, events, contests, wiki, etc. 我目前有一个ASP .NET MVC / EF4项目,其中包含许多自主功能,例如博客,事件,竞赛,Wiki等。

The entities used by each system are all mapped to my database through one giant EDM file. 每个系统使用的实体都通过一个巨大的EDM文件映射到我的数据库。

This works well for the main site, but I also have a few personal sites where I want to reuse just the blogging functionality from the mains ite. 这对于主站点来说效果很好,但是我也有一些个人站点,我只想重复使用mains站点中的博客功能。

My biggest problem is that due to the mac daddy EDM file, my blog sites have to constantly have their database schemas updated to reflect changes made to areas of functionality that they don't use (ie changes to the events system). 我最大的问题是,由于使用了Mac daddy EDM文件,我的博客站点必须不断更新其数据库架构,以反映对他们不使用的功能区域所做的更改(即对事件系统的更改)。

The only other gotcha is that there are some entities (Users and Tags) that have relationships with entities from each area of functionality, making it hard to simply split each area of functionality off into its own EDM. 唯一的难题是有些实体(用户和标签)与每个功能区域的实体都有关系,因此很难简单地将每个功能区域拆分为自己的EDM。

With all of this said, I'm trying to figure out the most efficient way to set this up. 综上所述,我正在尝试找出最有效的方法来进行设置。

Should I go down the road of splitting up the EDMs by each area (blogs, events, contests, wiki) and figuring out a way to maintain relationships for the User and Tag entities? 我是否应该按照每个领域(博客,事件,竞赛,Wiki)划分EDM并找出维护用户和标签实体之间关系的方法?

Or should I just perhaps be creating an EDM for each website that only maps the entities that it will actually need? 还是我应该为每个仅映射其实际需要的实体的网站创建EDM? The only problem with this is that my repository layer takes in a UnitOfWork/ObjectContext, and by creating new ObjectContexts for each site I'd have problems reusing my repository code. 唯一的问题是我的存储库层接受了UnitOfWork / ObjectContext,通过为每个站点创建新的ObjectContext,我在重用我的存储库代码时会遇到问题。

You could setup a WCF service and then pass your data via a JSON contract. 您可以设置WCF服务,然后通过JSON合同传递数据。 That way you'd have a central service that holds your EF data, and then just exposes functions based on what the your different applications need. 这样,您将拥有一个包含EF数据的中央服务,然后仅根据您的不同应用程序的需求公开功能。

Its more short term work to setup (hopefully your service/repository layer was done with IoC in mind to allow it to be easily plugged in) but if your EF data changes a lot, it means you can update the one central service without having to update each of your clients apps. 它需要更短期的设置(希望您的服务/存储层是在考虑IoC的情况下完成的,以便可以轻松插入),但是如果您的EF数据变化很大,则意味着您可以更新一个中央服务而不必更新您的每个客户端应用。

There's a good reference thread here on SO: https://stackoverflow.com/questions/973017/where-to-find-good-wcf-video-tutorials 在SO上有一个很好的参考线程: https : //stackoverflow.com/questions/973017/where-to-find-good-wcf-video-tutorials

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM