New Posts New Posts RSS Feed: Splitting entity in multiple databases
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Splitting entity in multiple databases

 Post Reply Post Reply
Author
s_tristan View Drop Down
Newbie
Newbie
Avatar

Joined: 10-Mar-2011
Location: Ukraine
Posts: 18
Post Options Post Options   Quote s_tristan Quote  Post ReplyReply Direct Link To This Post Topic: Splitting entity in multiple databases
    Posted: 28-Sep-2011 at 6:27am
We are developing a SaaS application that contains:
  • one shared nonsecured database with reference data (countries, regions, cities etc.)
  • one separate database per each customer of application
So there are a simply entity - Address with such properties:
  • Zip (string)
  • Country (reference to Country)
  • Region (reference to Region)
  • City(reference to City)
  • Address line (string)
We want to store Address entity in the customer database, while the references (Country, Region, City) are in the shared database.

How to implement this scenario with DF?
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 28-Sep-2011 at 4:18pm
Hi Tristan,

You would define a model (EDMX) for the customer database and another model for the shared database. A DevForce EntityManager can work with multiple models as shown in these examples:

By default, there won't be navigation properties that navigate from one model to another (DevForce/EF doesn't know about these relationships), but you could write these yourself in the partial classes.

However, I'd recommend that you use a repository pattern in a different assembly to navigate across models. A repository pattern in general is a good idea, and it will save you from having to deal with any circular reference issues if you want to navigate bidirectionally between the models.

For example, one of the methods in the repository might look like this:
country = Repository.GetCountry(address);

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down