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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:58:38+00:00 2026-06-15T23:58:38+00:00

I am new to Entity Framework , after a crash course and some playing

  • 0

I am new to Entity Framework, after a crash course and some playing around my employer decided to use ef 5, code first.

I have separated the dbcontext derivative along with the repositories and connection strings in a assembly on its own. The idea is to create an assembly which can be reusable across projects.

The connection string in the database assembly looks like this:

<add name="LmsDb" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=LmsDb;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\LmsDb.mdf;;MultipleActiveResultSets=true" providerName="System.Data.SqlClient" />

While the connection string on assemblies using the database project (the clients) looks like this:

<add name="LmsDb" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=LmsDb;Integrated Security=SSPI;MultipleActiveResultSets=true" providerName="System.Data.SqlClient" />

I have created a MVC project which works just fine with this and all my integration tests works well with this connection string.

The problem occurred when I had to create some kind of scheduler logic to go through the database at some configurable intervals and do some actions according to the data there. I decided to test this out by creating a simple Windows Service with a Timer that executes the ef 5 code for some queries.

The timer is set to execute a Select all query every minute, but when this happends my query returns no results although I know that there is data in the database.

When I look at the DbContext.Connection.State, its set to Closed.

What am I doing wrong ?

I tried opening the connection explicit by using ((ObjectContextAdapter)my context).ObjectContext.Connection.Open() according to Julie Lerman.

This didn’t seem to help any though.

  • 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-15T23:58:39+00:00Added an answer on June 15, 2026 at 11:58 pm

    This got resolved. Please look at my comment.

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

Sidebar

Related Questions

I wish to use Entity Framework Code-first for a new project. So i decided
I am new the code-first Entity Framework. I have tried a few things now,
I'm new to Entity Framework and am using Database First. I have inherited a
I am new to Entity Framework but im trying to model my code after
I'm trying to use Entity Framework for the first time, and have come a
After reading several questions/answers about unit testing Entity Framework, I have decided to forgo
I am currently using Entity Framework 4.2 with Code First. I currently have a
I have a database that was created with the Entity Framework's code first approach.
I heard about the new entity framework for .net, and decided to modify my
When adding a new Entity Framework object to a database, how could one have

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.