locked
Single EDMX with Multiple Databases... Possible? RRS feed

  • Question

  • I currently have a EDMX file that is mapped to my model database.  I'm wanting to bring in entities from the aspnetdb (Membership/Roles) database into my EDMX file.  Is this possible?  I can't seem to find any goodness about multiple-database support in EF and I remember this being a highly-touted feature.

    Thank you!
    Michael


    Promotcho Bad Self! http://promotely.com
    Sunday, June 7, 2009 8:57 PM

Answers

  • The EF has a provider model so that more than one type of database can be used with it, but the EF does not support a single model mapped to more than one database (and as far as I know this was never one of the features planned or promised, but it's quite likely that the communication was less than completely clear).

    The only way to have more than one database in a single model is with linked tables which make multiple databases look like one as far as the client is concerned, so this isn't really a feature of the EF.

    - Danny


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Monday, June 8, 2009 5:51 AM

All replies

  • The EF has a provider model so that more than one type of database can be used with it, but the EF does not support a single model mapped to more than one database (and as far as I know this was never one of the features planned or promised, but it's quite likely that the communication was less than completely clear).

    The only way to have more than one database in a single model is with linked tables which make multiple databases look like one as far as the client is concerned, so this isn't really a feature of the EF.

    - Danny


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Monday, June 8, 2009 5:51 AM
  • hi, daniel

    i think this is a draw back not step forward, Microsoft keep advertising EF as a Conceptual model and a data model, so s/he can create conceptual model including Membership table but he can't fill it with data untill he link table in the database (what if the database doesn't support the linked table or is he obliged to use just SQL SERVER?)

    so instead of producing an easy way to access data they just complecated it in the form of SDL , CDl .... EDMX , the EF doesn't allow more than one connection and also doesn't provide an easy way to access data manualy,

    i think EF model some how close to DATASET , in dataset i still can hardcode tableAdapter or just a simple command to fill table with data but not obliged to use the generated command , the command still easy to hardcode which is not the case in EF, really i hope if you can adapt an easier solution For Manualy Hard Coded EF command like what this brilliant guy did here its the link and i hope to find something easy like this in EF  Simple Data Access in C# , just provide something easy like that for mapping and make the coder resposible for navigation property or what you see but just provide something simple.

    Michael is not the only person who asking about this i did before many times till i gave up and i thought because of my bad english no one could understood me like this post  or this post and there are others where asking the same questions like this one

    in my case the data were in 2 different types of databases MS SQL SERVER and INTERBASE which use different Datatypes, it ended up i had to re write the entire EDMX for all tables. because i just wanted to populate one table from the interbase i was asked to write the other classes SSDl because of navigation properties, so i gave up on EF (but still think it will be better than Dataset in the future but i have to wait i can't use it right now because it has problems in N Tire environment)


    thanx
    http://fromisraeltolebanon.info
    Tuesday, June 9, 2009 4:43 AM
  • Is EF going to at least support multiple databases on the same server? Wouldn't it just be a matter of using fully qualified table/view/sproc/udf names and allow to switch databases in the designer.
    Tuesday, June 9, 2009 5:21 AM
  • Multiple databases on the same server is something we could theoretically support (albeit with some limitations since you can't have relationships that cross databases, etc.).  Unfortunately even this doesn't come for free, and it was prioritized lower than the other areas we have invested in for dev10.  This will have to wait until a future release.

    - Danny
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, June 11, 2009 7:09 AM
  • @shakalama,

    We don't dispute the potential usefulness of a model which includes elements from more than one database, but this is a much bigger undertaking than you might think.  The curent focus of the team is to provide great experiences over one database at a time.  Eventually we may look at the broader story, but for now our suggestion is to build database-crossing solutions at a higher level on top of the EF.

    - Danny
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, June 11, 2009 7:17 AM
  • If your database supports Synonyms, you can create a single edmx file that treats your Synonyms the same as it would regular database objects.

    I wrote how to do it here if you're interested, using SQL Server 2005 and EF4.

    Basically you have one working edmx file, an edmx file per database, and a Merge script which merges the individual edmx files into the working copy. This makes maintenance easy. It also allows you to create links between the two databases. Examples of how it works, and the merge script is in the link above.

    • Proposed as answer by Rachel53461 Friday, August 5, 2011 1:26 PM
    Friday, August 5, 2011 1:25 PM