Core Edmx extension, several Edmx in EF4

We have an EF4 EDMX that contains ~ 300 objects that are used in our basic product package (objects imported from the database).

When we get new customers, most often they want to store additional information and develop user processes that are outside our business domain and are fully customizable. For instance. We have a contract with a security company, and they wanted to store information about their security levels and have processes that operate at these levels.

In each case, we need to add custom AND / OR tables or add custom fields to existing objects. We had a good way to do this using previous technologies in which the libraries of the main classes were not loaded using custom tables, etc. We simply inherited from the main entity (equivalent to EntityObject in EF) in the user class library and added settings as needed.

Similarly, we do not want to add these user tables and attributes to our main EDMX. We essentially want to “inherit” from the main EDMX in the new custom EDMX in a separate class library where we can add settings. Inheritance will allow us to do our best in Core EDMX plus a little more.

We use the t4 template to create our repositories based on this blog post (we do not use a model-based approach):

http://geekswithblogs.net/danemorgridge/archive/2010/06/28/entity-framework-repository-amp-unit-of-work-t4-template-on.aspx

Can we extend EDMX as we require?

We came up with one hacker solution - an extension of the method for the main objects, which returns the user object in a separate EDMX, as shown below:

  public static class CoreEntityExtensions
  {
    public static EntityConnection EntityConnection;

    public static CustomUserEntity CustomUserDetails(this User coreUser)
    {
      ICustomUserEntityRepository customUserRepository = new CustomUserEntityRepository(EntityConnection);
      return customUserRepository.All().SingleOrDefault(u => u.id == coreUser.id);
    }
  }

This is not ideal, although for several obvious reasons.

Any help is greatly appreciated.

+3
source share
1 answer

, , NHibernate . , , NH DLL.

, , , , .

0

Source: https://habr.com/ru/post/1780319/


All Articles