I have a multi-tenanted database where each client has a separate db instance, but the schema/edmx model is identical for all clients. I'm pre-generating a single set of views to use across all the client databases in my MVC based web application (I'm
using multiple models, EF 4.1). Everything works fine when I connect to any one client and perform entity queries and save operations, which is good and illustrates that all the basics have been done correctly and there are no dll mismatches.
However, I'm encountering a strange problem where I receive the below exception when I log out of one client and log into another client during the same session. Anytime I switch clients after performing a save operation the below exception occurs.
The only thing that changes from the applications standpoint is that the EF connection string is slightly different in the Intial Catalog value (so we know what instance to use) when creating new ObjectContexts. Does the uniqueness of the connection
string come into play when the views are cached in the app domain when it comes to update views?
System.Data.EntityCommandCompilationException: An error occurred while preparing the command definition. See the inner exception for details. ---> System.Data.MappingException: The mapping
and metadata information for EntityContainer 'SystemCoreDB'
no longer matches the information used to create the pre-generated views.
Thanks Allen. I made an assumption when I said my App was MVC, so I thought it best if I was explicit in indicating that I'm using POCOs in a detached mode with no laxy loading or proxies. I don't believe this really influences the bug
but thought I'd mention it.