Search code examples
entity-frameworkentity-framework-4efpocoadapter

How can I create separate projects containing relative entities (POCOs) using EF and then access them from a single project


Consider I want to develop a large enterprise application. In my application I have several modules something like:

Purchase, Inventory, Accounts, Payroll, HR and so on. I will develop each of these modules individually.

I want to create a Class Library Project that consists of my entities that means POCOs.

What will be good a practice for creating entities?

  1. Creating all entities in a single project, or:
  2. Creating separate project containing relative entities.

If I want to create a separate project containing relative entities, then how do I create them and how do I integrate them?


Solution

  • We are currently working with smth like that: several modules with own entities. Each module has its own POCO classes that can depend on "common use" classes (User or Role, for example).

    Poco classes can be declared in any namespace. The main thing that connects your poco classes to Database is DbContext class. You can create several DbContexts for single database (one for a module in our case). This dbContexts can have own pocos and can use any number of pocos from other Contexts (DbSet field for one poco should be declared in only one DbContext). All DbContexts should use the same connection string. All tables and dependencies will be created automatically. Sounds like magic.

    Ask if you need any details.

    If you have time for research look through nopCommerce project. They implemented what you are interested in. http://nopcommerce.codeplex.com/