Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5952255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:39:21+00:00 2026-05-22T17:39:21+00:00

I have a class library that has it’s own model and connectionstring to the

  • 0

I have a class library that has it’s own model and connectionstring to the database. Standalone, this works all fine and it’s no problem to retrieve data from the database. The idea of this library is to create a dll and reference that in another application.

In my case I have an MVC3 web application with it’s own model and connectionstring. I referenced the class library, added a second connectionstring and the whole application builds. But when I am running the appliction and actually call a method on the referenced library, I get an EntitySqlException saying “‘MyTable’ could not be resolved in the current scope or context. Make sure that all referenced variables are in scope, that required schemas are loaded, and that namespaces are referenced correctly. Near escaped identifier, line 1, column 1.”

I made sure that the model files of the referenced library are also copied to the bin directory of the mvc project and my web.config looks like this:

<configSections>
<section name="DefaultArchitecture" type="DefaultArchitectureConfiguration"/>
</configSections> 

<DefaultArchitecture defaultContainerName="defaultContainer" connectionStringName="defaultContainer"/>

<connectionStrings>
<add name="defaultContainer" connectionString="metadata=res://*/MvcModel.csdl|res://*/MvcModel.ssdl|res://*/MvcModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=cloudaddress;Initial Catalog=main catalog;User ID=user;Password=pass;Encrypt=true;Trusted_Connection=false;trustServerCertificate=true&quot;" providerName="System.Data.EntityClient" />
<add name="secondContainer" 
     connectionString="metadata=~\bin\libmodel.csdl|
                                ~\bin\libmodel.ssdl|
                                ~\bin\libmodel.msl;
                       provider=System.Data.SqlClient;
                       provider connection string=&quot;
                       data source=cloudaddress;
                       initial catalog=othercatalog;
                       persist security info=True;
                       user id=user;
                       password=pass;
                       multipleactiveresultsets=True;
                       App=EntityFramework&quot;" 
      providerName="System.Data.EntityClient" />

If I change the defaultcontainername to the secondcontainer…it works fine for the referenced library but of course no longer for the defaultcontainer.

Question is…how can I use both models in my mvc project by having a referenced class library with it’s own model (and own database) without having the problem that it cannot resolve one of the entities.

Hope my question is clear. If not, please let me know so I can provide more info.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:39:22+00:00Added an answer on May 22, 2026 at 5:39 pm

    Eventually it turned out to be a context problem. I was still using the wrong context when calling the class library. I fixed it by implementing an idisposable and switching to the correct context on creationg of the library’s service class en switching back on disposal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class library with all my database logic. My DAL/BLL. I have
I have a Class Library that has an AssemblyVersion of 1.0.0.0 and has to
Let's say you have a class library project that has any number of supplemental
I have a C# .NET 2.0 project A (class library) that has a form
i have a winsock component made with vb.net in a class library that has
I have created a VB.NET 2008 Class Library that has, for the most part,
I'm building a class library that will have some public & private methods. I
We have a class library where we keep a lot of the stuff that
I have a C# (2008/.NET 3.5) class library assembly that supports WPF (based on
I have a .NET class library containing a class with a method that performs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.