Entity framework: retrieving data from different databases
I have the following scenario
I have 4 different (sql server) databases (legacy), one for each geo (NA,AP,LA,EMEA). The schema is the same in all the db's.
I am in the process of creating a front-end which wi开发者_如何转开发ll go across 4 different db's based on the users selection.I am thinking of using Entity framework. The db's are on different servers. What is the best way to create the entities? should i create 4 different edmx? there will be scenarios when the users results need to come from one or more db's
Thanks,
Nagendra
If databases are exactly same you can create edmx file only for one of databases (the mapping will be same for all DBs) and use 4 ObjectContext instances with different connection strings. The problem here can be with your second requirement. Querying more DBs means that you have to query each DB separately and merge/union results in memory on the application server. So such scenario is not very good for advanced querying where you need to run complex queries on all databases at the same time.
精彩评论