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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:07:49+00:00 2026-06-18T08:07:49+00:00

I m just using EF 5.0 and I’ve recreated a very simple DbContext that

  • 0

I m just using EF 5.0 and I’ve recreated a very simple DbContext that was working as is with EF 4.1.

Here context and model

public class AgenciesDatabaseContext : DbContext 
{
   public DbSet<Agency> Agencies { get; set; }
}

[Table("QryAgency")]
public class Agency
{
   [Key]
   public string CardCode { get; set; }
   public string DisplayName { get; set; }
   public string CardFName { get; set; }
   public string Address { get; set; }
   public string ZipCode { get; set; }
   public string City { get; set; }
}

I set in global.asax initializer for this context as null because the table already exists

Database.SetInitializer<ExtranetCentralizerContext>(null);

Here’s the connection string in web.config :

<add name="AgenciesDatabase" providerName="System.Data.SqlClient" connectionString="..."/>

When I try to use the DbContext in the repository I get this error :

InnerException = {"Invalid column name '...'.\r\n Invalid column name '...'.\r\nInvalid column name '...'."}

It’s strange because I could see that there is not connection made to my database.

What I don’t understand is that I can make it work if I pass the connection string to the context like this :

 public class AgenciesDatabaseContext : DbContext 
 {
     public DbSet<Agency> Agencies { get; set; }

     public AgenciesDatabaseContext ()
            : base("AgenciesDatabase")
     {

     }
 }

There everything work fine. So my question is : isn’t EF suposed to use the connection string that matches it’s name (in this case AgenciesDatabase) ??? What makes it fail in this case ?

  • 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-18T08:07:50+00:00Added an answer on June 18, 2026 at 8:07 am

    in your app.config the name should be AgenciesDatabaseContext, not only AgenciesDatabase.

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

Sidebar

Related Questions

K.. I'm just using a simple script I found here: import os from os
Just using this as an example... Here are the columns in my UserProfile table:
I'm just using a simple self.customerTextField.text = @text; but I would like there to
I know that just using rand() is predictable, if you know what you're doing,
Right now I'm just using a simple WHERE name LIKE '%$ser%' But I'm running
Just using php, is it possible to create a button via html that reacts
(Objective C) Just using simple AudioServicesPlaySystemSoundID and its counterparts, but I can't find in
i am developing simple game application just using pan gesture and cgaffinetransform rotate application
I'm using 2 tables Let's say (There's more to these tables but that's just
I'm just using StarUML to create my UML Class diagram and something is bothering

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.