Link to home
Start Free TrialLog in
Avatar of WestcountryBusiness
WestcountryBusiness

asked on

Using Entity Framework over Multiple Databases

I'm new to entity framework and have a project I would like to use it with.  There are two separate applications, each with it's own database.  I am looking to add some functionality that would benefit both applications.  It is the option to attach documents (attachments) to business objects.  The business objects will be different in each application, but the functionality of the attachment (adding, removing, emailing etc.) will be the same across both.

Both databases will have an attachments table:
Attachment_Id
Attachment_Type
etc.

Then each database has a number of tables linking the Business Objects (tables) to the document_Table

e.g.
DB1
Table Name: StockItem_Attachments
Stock_Item_Id
Attachment_Id

Table Name: Vehicle_Attachments
Vehicle_Id
Attachment_Id

etc.

and in DB2
Table Name: Employee_Attachments
Employee_Id
Attachment_Id

etc.

So, how do I reduce duplication of Code here?  Do I have one Entity Framework for AttachmentEntities and somehow have it contain both StockItem_Attachments and Employee_Attachments (both entities that inherit from attachments).  If so, how?

Or do I have separate Entity Frameworks then if so how (or where) do I create a method or partial class that applies to all attachments (e.g. OpenAttachement)?

I'm using Visual Studio 2015 with Entity Framework 6
ASKER CERTIFIED SOLUTION
Avatar of WestcountryBusiness
WestcountryBusiness

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial