Modular applications with Code Entity Framework and ASP.NET MVC only

By modular applications, I mean applications in which the basic functionality and data model can be extended without changing the code of the main application.

This is a popular approach, for example. open source such as SugarCRM or VTiger.

This approach can be performed in an asp.net mvc application using areas or (portable areas from MVC contrib), which allow you to add new controllers and views to separate assemblies without affecting the core DLLs.

The problem arises when it is necessary to expand the basic data model of the application. This is not possible in any practical sense with an entity infrastructure where the model definition is centralized in the Edmx file. This approach does not allow adding a new table that would refer to the table of the base module in the new assembly.

I noticed that Orchard CMS achieves full modularity using nHibernate (which says, given that they have Microsoft support, and the project has been called a technology showcase). Nhibernate allows this modularity through the POCO approach. Each object / table is defined in a separate file, which, obviously, is a way to work with modular applications.

However, there is only hope for an Entity Framework Code Only approach that generates the Edmx model at runtime using POCO definitions. Has anyone tried this approach to distribute data model definitions in separate, pluggable projects?

+7
source share
1 answer

I achieved this using EF Code First and a combination of GUI extension points on the main module. This led to:

  • Each module is treated as a standalone application (except for the GUI)
  • Each module has its own database (since the code first crashes and re-creates the database)
  • Each module can duplicate the necessary data in another module
  • Each module is a service.
  • Each module can extend the GUI through the main extension points through the IoC container
  • Modules can communicate with each of them through asynchronous messaging (nServiceBus) and synchronous RPC (WCF)

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

With EF Code First, if you manage your database manually (i.e. don't drop or recreate), you can take some of the concepts above and simplify. To support it, you might need a custom IDatabaseInitializer , but this should be possible.

+3
source

All Articles