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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:37:22+00:00 2026-05-24T11:37:22+00:00

I’ve created a new MVC 3 website using EF 4.1 with DB first approach.

  • 0

I’ve created a new MVC 3 website using EF 4.1 with DB first approach. I’ve created the edmx file and then the DBContext (the new 4.1 feature) classes. all went well.

Then, I’ve created new controllers using the automatic creation for DBContext. All wen’t great.

Now, that I’m trying to fire up the website it won’t connect to the connection string itself created.

Here is the connection string:

<add name="PizzaByMeEntities"
     connectionString='metadata=res://*/Models.PizzaByMeModel.csdl|
                                res://*/Models.PizzaByMeModel.ssdl|
                                res://*/Models.PizzaByMeModel.msl;
                       provider=System.Data.SqlClient;
                       provider connection string="data source=(local);
                                                   initial catalog=PizzaByMe;
                                                   integrated security=True;
                                                   pooling=False;
                                                   multipleactiveresultsets=True;
                                                   App=EntityFramework;"'
     providerName="System.Data.EntityClient" />

When I fire up the website I get:

A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: SQL
Network Interfaces, error: 26 – Error Locating Server/Instance
Specified)

The strange part is that if I remove the connection string – I still get the exact same error. I guess that the EF just can’t find the Connection String even when it’s there.

Any ideas?

Thanks!

EDIT:

My DBContext is as follows:

public partial class PizzaByMeEntities : DbContext
{
    public PizzaByMeEntities()
        : base("name=PizzaByMeEntities")
    {
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        throw new UnintentionalCodeFirstException();
    }

    public DbSet<X> Xs{ get; set; }
    public DbSet<Y> Ys{ get; set; }
    public DbSet<Z> Zs{ get; set; }
}

EDIT 2:

the working connection string is this:

  <add name="PizzaByMe" connectionString="Data Source=(local);initial catalog=PizzaByMe;integrated security=True;pooling=False;multipleactiveresultsets=True;" providerName="System.Data.EntityClient" />

Though to make it work – I just used direct ADO.NET connection.

  • 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-24T11:37:23+00:00Added an answer on May 24, 2026 at 11:37 am

    Your derived DbContext class must have the same name as your connection string if you have only implemented a default constructor (or no constructor at all)

    public PizzaByMeEntities : DbContext
    {
        public PizzaByMeEntities()
        {
            // ...
        }
    }
    

    If your context has another name then you must specify the name of the connection string in the constructor:

    public PizzaByMeContext : DbContext
    {
        public PizzaByMeContext() :
            base("name=PizzaByMeEntities")
        {
            // ...
        }
    }
    

    Here are details about connections and connection strings with DbContext: http://blogs.msdn.com/b/adonet/archive/2011/01/27/using-dbcontext-in-ef-feature-ctp5-part-2-connections-and-models.aspx

    Edit: Another guess

    The connection string must be in the web.config of your MVC app, not in an app.config of a class library project where you possibly have your EF model and DbContext. Is it?

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want use html5's new tag to play a wav file (currently only supported
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small

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.