Back to list
Views:   10.3K
Replies:  2
Archived

EntitityFramework with Repository Layers

 
 Hi,

   There are lots of articles about EntityFramework with Repository Layer. We are using it like  below
  
   for the Account  -->AccountRepository
   fo the User--> UserRepository  ...  like so.

  But we always use one datacontext ,one entity.
 
  Should we seperate entities   like AccountEntities for AccountRepository , UserEntities for UserRepository ?

 Thanks,

 Best Regards..
Volkan Genç, Feb 24, 2012
Reply 1

Maintaining sepearate entities is the preferred choice over a entity will all data/ entity objects. There helps out by loading the specific set of data objects related to the respective repository. In your case, you can have Account Entities which deals with Account module only. Just incase a situation arrives where in you need to club both user and account entity objects, go for unit of work pattern (transaction over both repositories).

Simple words, Yes you can seperate the entities like Account Entities for Account repository and use the same data context. Load respective repositories based on the modules (Account/ User), use unit of work for persisting data on both the repositories.


Hope this helps.
Pavan Kumar Kota, Apr 25, 2012
Reply 2
It is recommended to use a single context but separate entities for each domain object.
Siva M, Mar 01, 2012


Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas.      Vsn 1.2.2