genxgeek
genxgeek

Reputation: 13367

How to add a table via .edmx from another database in EF4.1/MVC3?

I have an existing database context (database1) and .edmx that contains tables from database1. I need to add a couple of tables from another database2. How can I do this by right clicking on my .edmx and selecting "Update model from Database..." but be able to select the tables from database 2 instead of database 1?

Upvotes: 1

Views: 676

Answers (2)

Adam Tuliper
Adam Tuliper

Reputation: 30152

You can't however an alternative here is to:

  1. Create a separate edmx file. You CAN have more than one edmx file.
  2. Use code first and the entity framework power tools (you'll need to download those and then right click in our project and you'll have a new menu option for Entity Framework) and reverse engineer both existing databases into their code counterparts (since you are using EF 4.1)

Upvotes: 2

BNL
BNL

Reputation: 7133

You can't directly do this. An Entity Framework context is tied to a single DB.

You can create a view that links to your other db and use that.

Upvotes: 2

Related Questions