-1

I have to build an mvc application which connects to two different database. i need to have a menu say Employees > Which will open a create Employee page which need to be connected to Employee database (sql)and all the other menus/pages whould point to another database.

Can any one help me with the best approach with Entity Framework 6 Code First using MVC 4.

Tieson T.
  • 20,774
  • 6
  • 77
  • 92
Cheppy
  • 5
  • 1
  • 6
  • you can either, in code, have it change the connection string of your context or have 1 DB where SPROC's are being called and IT can co-ordinate which DB and tables to hit. you could also have multiple contexts one for each DB but maybe difficult to maintain and easy to mess up. – Ahmed ilyas Nov 20 '15 at 10:59

1 Answers1

0

Just create a model for each database, each one having it's own entities, connection string and so on. In EF 6 you can even use the same context to host multiple database models.

http://olivierhelin.com/blog/entity-framework/entity-framework-6-one-entity-data-model-multiple-databases-2

Using entity framework on multiple databases

Community
  • 1
  • 1
Oscar
  • 13,594
  • 8
  • 47
  • 75