none
Different databases - adding a database to an existing model RRS feed

  • Question

  • I have generated an existing model that I have used successfully. When the model (.edmx) was generated I had the model generated from a database. Now, because of the limitation of EF in handling more than one context I would like to add a table that exists on a different database to the existing context but I am not sure how to proceed. I tried adding a new entity but the prompt seemed all wrong.  I basically want to generate the model from the database but merge to generated code in with my previously generated model. Ideas?


    Kevin Burton

    Monday, July 30, 2012 5:45 PM

Answers

  • Hi KevinBurton,

    Welcome to MSDN Forum.

    I'm afraid we can't add models from different databases to one edmx file, EF doesn't support it, please refer to this link, this is the feature suggestion, you can vote up it.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us


    Tuesday, July 31, 2012 2:12 AM
    Moderator

All replies

  •  You add another database with a model, then you have to treat it
    separately from the other model.
     
    Monday, July 30, 2012 7:55 PM
  • I am not sure how to add another database. I only see options for adding an entity, assocaition, etc. 



    Kevin Burton

    Monday, July 30, 2012 8:44 PM
  • On 7/30/2012 4:44 PM, KevinBurton wrote:
    > I am not sure how to add another database. I only see options for adding
    > an entity, assocaition, etc.
    >
    How did you add the first model to the solution? You do it the same way
    and the result will be another model with its own edmx and its own
    connection string in the solution.
     
    Monday, July 30, 2012 8:54 PM
  • Because EF doesn't support multiple contexts in a query I want the new table from a different database to be a part of the existing context. If I click on the existing context I cannot add another database or table. There isn't a prompt for that. Basically I would like to merge two different .edmx and the associated code together so I can do a query across multiple databases. If I have a separate edmx and context then EF will complain that I am doing a query across more than one context.

    Kevin Burton

    Monday, July 30, 2012 9:36 PM
  • Hi KevinBurton,

    Welcome to MSDN Forum.

    I'm afraid we can't add models from different databases to one edmx file, EF doesn't support it, please refer to this link, this is the feature suggestion, you can vote up it.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us


    Tuesday, July 31, 2012 2:12 AM
    Moderator