5

I have two entities, each from a different database and therefore different edmx files. There is, however, an infered relationship between them.

Foo has many Bars for example.

What's the easiest way to do this join in the EntityFramework, with fewest database calls?

Thanks.

NikolaiDante
  • 18,469
  • 14
  • 77
  • 117

2 Answers2

4

You can do this by adding cross-model navigation properties. This requires manually editing the EDMX. There is an example, including LINQ to Entities, here.

Craig Stuntz
  • 125,891
  • 12
  • 252
  • 273
  • 1
    Do you know if the generated SQL goes cross database or does it handle it as a call to database a, then a call to database b? – NikolaiDante Dec 18 '08 at 14:24
1

You can do this by using Views to represent data in the other database. Read about cross database joins in EF

BritishDeveloper
  • 13,219
  • 9
  • 52
  • 62
  • I apply this view model. But when you need a new entity contains some properties from one edmx and some other properties from other edmx. Beside this you want to get new instance of this new entityset and do CRUD operations with this. Finally you need to seperate this entityset for diffrent models. We do like that. On the "Bus" project side one of my friend developed a model like that . You can join diffrent entities from diffrent Models with our framework and onSubmit each entity find his path. But I'm still looking for better practices. – Davut Gürbüz Apr 14 '12 at 15:43