模块化应用程序与实体框架code Only和ASP.NET MVC [英] Modular applications with Entity Framework Code Only and ASP.NET MVC

查看:171
本文介绍了模块化应用程序与实体框架code Only和ASP.NET MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过模块化的应用我的意思是应用中的基本功能和数据模型可以在不修改核心应用程序code进行扩展。

By modular applications I mean applications in which base functionality and data model can be extended without modifying core application code.

这是一个与例如,一个流行的方法。开源标准物质像SugarCRM的好vtiger或。

It's a popular approach with eg. open source CRMs like SugarCRM or VTiger.

这方法可能使用或地区(从MVC的contrib便携式地区)允许添加新的控制器和视图在单独的组件,而不会影响核心的dll应遵循的asp.net MVC应用程序。

This approach may be followed in asp.net mvc application using Areas or (portable areas from MVC contrib) which allow adding new controllers and views in separate assemblies, without impacting core dlls.

当一个人想扩大基本应用程序的数据模型,就会出现问题。这是不可能与实体框架,模型定义在EDMX文件集中任何实际意义。这种做法不允许添加,将涉及到一些基本模块表在新装配的新表。

The problem arises when one wants to extend the base application's data model. It's not possible in any practical sense with entity framework where the model definition is centralized in the Edmx file. This approach doesn't allow adding a new table that would reference some base module table in a new assembly.

我注意到,该果园CMS通过使用NHibernate实现了全模块化(这是在告诉,因为他们有微软的支持,该项目是为了作为一个技术展示)。 NHibernate的允许这种模块化感谢POCO的方法。每个实体/表是在一个单独的文件,它显然是去模块化应用程序的方式定义

I've noticed, that the Orchard CMS achieves full modularity by using nHibernate (which is telling, given they have Microsoft backing and the project was meant as a technology showcase). Nhibernate allows such modularity thanks to the POCO approach. Each entity/table is defined in a separate file which obviously is the way to go with modular applications.

有是,但是,与实体框架code唯一的方法,它产生使用POCO定义在运行时EDMX模型的希望。有没有人尝试这种方法在一个单独的,可插入项目分发数据模型的定义?

There is, however, a hope with Entity Framework Code Only approach, which generates Edmx model in runtime using POCO definitions. Has anyone tried this approach to distribute the data model's definitions in a separate, pluggable projects?

推荐答案

我已经实现了这个使用EF code首先与GUI扩展点的核心模块的组合。这导致:

I have achieved this using EF Code First and a combination of GUI extension points on the core module. It resulted in:


  • 每个模块的治疗作为一个独立的应用程序(除GUI)

  • 每个模块都有它的自己的数据库(如code第一滴和放大器;重新创建数据库)

  • 每个模块中的另一个模块可以复制所需的数据

  • 每个模块是一个服务

  • 每个模块都可以通过核心扩展GUI的扩展点通过IoC容器

  • 模块可以相互通信,无论是通过的异步消息(nServiceBus)和同步RPC (WCF)

  • Each module is treated as a standalone application (except for GUI)
  • Each module has it's own database (as code first drops & recreates database)
  • Each module may duplicate needed data in another module
  • Each module is a service
  • Each module can extend the GUI through core extension points via an IoC container
  • Modules can communicate with each either via asynchronous messaging (nServiceBus) and synchronous RPC (WCF)

请注意,这是一个企业应用,我们设计的SOA。

Please note that this is an enterprise application that we designed for SOA.

使用EF code首先,如果你手动管理数据库(即不降&放大器;重建),你可以采取上述的一些概念和简化它。你可能需要一个定制的 IDatabaseInitializer ,以支持它,但它应该是可能的。

With EF Code First, if you manage your database manually (ie. don't drop & recreate), you could take some concepts above and simplify it. You may need a custom IDatabaseInitializer to support it but it should be possible.

这篇关于模块化应用程序与实体框架code Only和ASP.NET MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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