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 6146651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:58:55+00:00 2026-05-23T18:58:55+00:00

I am having trouble changing the connection string used by entity framework code first

  • 0

I am having trouble changing the connection string used by entity framework code first for my project. I created a MVC3 project and then added two projects, DomainClasses and DataAccess.

The DomainClasses project has one class file named Classes.cs with one class:

public class User
{
    public int ID { get; set; }
    public string Username { get; set; }
    public string EmailAddress { get; set; }
    public string Password { get; set; }
    public int StatusID { get; set; }
    public DateTime DateCreated { get; set; }
}

The DataAccess project has one class file named PLNQDB.cs with one class:

public class PLNQDB : DbContext
{
    public DbSet<User> Users { get; set; }
}

I have a reference to each of these projects inmy MVC project and everything builds fine and runs and even creates the database file that I am able to save to and retrieve data from.

When running the project I can see in the Autos window the connection string being used under this.db.base.Database.Connection.base.ConnectionString =

"Data Source=.\\SQLEXPRESS;Initial Catalog=PLNQ.DataAccess.PLNQDB;Integrated Security=True;MultipleActiveResultSets=True"

My question is how do I override this autogenerated connectionstring to use my remote server. I have added a connection string to the web.config file of the MVC project.

  <connectionStrings>
    <add name="ApplicationServices"
         connectionString="Data Source=255.255.255.255;Initial Catalog=PLNQ;User ID=blah;Password=blah"
         providerName="System.Data.SqlClient" />
  </connectionStrings>

but everytime I run the project it still uses the auto generated connectionstring. I have also tried adding App.config files with the same connection string in both the DataAccess and DomainClasses projects.

What am I missing?

  • 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-23T18:58:55+00:00Added an answer on May 23, 2026 at 6:58 pm

    There are couple of options

    1 You need to name the connection string that matches the your DbContext class name.

    eg

      <connectionStrings>
        <add name="PLNQDB"
             connectionString="Data Source=255.255.255.255;Initial Catalog=PLNQ;User ID=blah;Password=blah"
             providerName="System.Data.SqlClient" />
      </connectionStrings>
    

    2 In your DbContext constructor call the base class constructor with the connection string name

    public class PLNQDB : DbContext
    {
        public PLNQDB():base("ApplicationServices"){}
    
        public DbSet<User> Users { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having trouble linking the Stomp.framework into an iPhone SDK application. http://code.google.com/p/stompframework/ I follow the
This should be simple but I'm having trouble changing some C code that uses
I'm having trouble figuring out how to get the testing framework set up and
I'm having trouble changing the font size of my TextInput tooltip. The text input
i am having trouble changing the height of the my rows dynamically, is there
I'm having trouble changing the section header for my grouped uitableview. I have tried
I'm having trouble changing the image in a DataGridViewImageCell on mouseover. According to a
am having some trouble with attempting to remove a memory leak from my code.
I'm having trouble changing the pinColor for an annotation in MapKit. When I don't
I am having trouble changing the text in a label. Can someone show me

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.