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

  • SEARCH
  • Home
  • 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 8538501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:07:59+00:00 2026-06-11T11:07:59+00:00

I have one application using MVC3 w/ Razor that has been working perfectly working

  • 0

I have one application using MVC3 w/ Razor that has been working perfectly working with one database. I am now encountering this error when trying to access the second database:

CREATE DATABASE permission denied in database ‘master’.

I assumed adding another DbContext class to the project would be the same process I used to add the first pre-created database, so I added the second connection string to the web.config just like this:

<connectionStrings>
<add name="DbContext1" connectionString="Data Source=db1.server.com;Initial Catalog=dbName1;User Id=db1;Password=*&#!$;" providerName="System.Data.SqlClient" />
<add name="DbContext2" connectionString="Data Source=db2.server.com;Initial Catalog=dbName2;User Id=db2;Password=*&#!$;" providerName="System.Data.SqlClient" />

I then added the second DbContext class to the application:

public class DbContext1 : DbContext
{
    public DbSet<Table1> Object1 { get; set; }

    public DbSet<Table2> Object2 { get; set; }

    public DbSet<Table3> Object3 { get; set; }

    public DbSet<Table4> Object4 { get; set; }
}


public class DbContext2 : DbContext
{

    public DbSet<Table1> Object5 { get; set; }
}

The problem appears when I try to access the second database. The first database is still working like a charm, but for some reason, the second database appears to be trying to create a new database rather than read the existing database at the end of the connection string. Any help would be greatly appreciated!

  • 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-06-11T11:08:00+00:00Added an answer on June 11, 2026 at 11:08 am

    Try explicitly selecting the context, either in the constructor of your classes:

    public class DbContext1 : DbContext
    {
        public DbContext1() : base("DbContext1")
        {
        }
        public DbSet<Table1> Object1 { get; set; }
    
        public DbSet<Table2> Object2 { get; set; }
    
        public DbSet<Table3> Object3 { get; set; }
    
        public DbSet<Table4> Object4 { get; set; }
    }
    
    
    public class DbContext2 : DbContext
    {
        public DbContext2() : base("DbContext2")
        {
        }
    
        public DbSet<Table1> Object5 { get; set; }
    }
    

    Or, overloading the constructor to accept a connection string, and calling it in your code:

    public class DbContext2 : DbContext
    {
        public DbContext2(string connectionString)  : base (connectionString)
        {
        }
    
        public DbSet<Table1> Object5 { get; set; }
    }
    

    and then when you create a new context:

    var context = new DbContext2("DbContext2");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one web application made using MVC3 Razor. Application starts properly in browser
i have one application which is build using VB.NET now i required to add
I have created one application in flex that is accessing the Java webservice using
I have built a web application using Java EE platform that sells one of
am using the application in this link http://www.jeasyui.com/tutorial/app/crud2.php .I have added one more column
I'm working on an iPhone application. I'm using Storyboard. I wanted to have one
I have a properly working ajax form in my MVC3 application except for one
I'm starting with a MVC3 application, using EF. We have a database with >
I have an ASP MVC3 application that has several HttpPost ActionResult methods. During a
I have one legacy web application based on struts2 (primarily using annotation). While debugging

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.