• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 109
  • Last Modified:

ER multiple DB

I'm using ER 4.0/4.5. My solution has a few projects. Aomng those projects, two of them have mapped two databases. Or say there are .edmx in two different projects in one solution. My question is - Can entityframework handle multiple database accessing? How? I need get data from two EF.  Thanks.
0
minglelinch
Asked:
minglelinch
  • 3
  • 2
1 Solution
 
Fernando SotoRetiredCommented:
Hi minglelinch;

You can not access the two databases through a single DbContext. You will need to instantiate one DbContext for each database and query each database separately and pull down the needed data and perform local queries on the two different result sets.
0
 
minglelinchAuthor Commented:
Thanks for your post. But I'm still wondering about "perform local queries on the two different result sets". How to do this or any further detail?
0
 
Fernando SotoRetiredCommented:
Hi minglelinch;

Let's give a hypothetical example. Lets assume you have two databases. In database A you have a table of Customers in database B you have the orders for the customers in database A. Let assume that you want to query all the customers that are located in New York City as well as all there Orders. The first thing to do is retrieve a collection of customers from database A and execute the query. The next thing to do is to retrieve a collection of orders using the CustomerID and execute that query. Now in local memory you have two collections one of Customers and the other of Orders. Now you can perform a Linq to Object query between the two collections to arrive at a final result set.
0
 
minglelinchAuthor Commented:
Thanks for the post.
0
 
Fernando SotoRetiredCommented:
Not a problem minglelinch, glad to help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now