8

I'm using Entity Framework 4 in an MVC3 project. I'm trying to access two different databases (A and B):

  • Databases A and B are completely different and unrelated.
  • Database A is a 'code first' SQL compact database.
  • Database B is a 'database first' SQL Server database.
  • I have straightforward queries on either database, no linking or cross-database joins.
  • Either database connection works if I remove the other DbContext from the project.

Now, when I try to query from database A, I'm getting an Exception "Could not find the conceptual model type for ".

I can't imagine that EF doesn't let you use different databases, so my question is: do I need to do something extra when creating a new instance of the appropriate DbContext, in order for this to work?

1
  • did you ever find a solution for this? im having the exact same problem (except i have just database A of which half has an edmx and half is code firsted) Commented Jul 25, 2011 at 5:59

2 Answers 2

2

I stumbled across this thread while trying to resolve the "Could not find the conceptual model type for" exception.
I am using EF 4.2 with multiple models. I implemented DbContext with one of my models to "try it out". When I compiled and ran, I received the exception above for an entity in a completely different model on a completely different database!

After much hassle I finally implemented DbContext to the other two models and everything ran fine.

I know this doesn't necessarily answer the question, but I wanted to leave this here for anyone else that has the same issue and stumbles across this post.

Sign up to request clarification or add additional context in comments.

Comments

1

Make sure you don't use the same entities name for both edmx files. You can change it manully opening a edmx with xml editor right clicking the file and open with.

Note that for some security reasons you can't nest the contexts. They can only be used separated.

1 Comment

Oh that's a good point; however, my entities do not have the same name or identifier. Incidentally, I only have an edmx file for the "database-first"-database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.