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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:10:56+00:00 2026-05-16T09:10:56+00:00

Error: The ObjectContext instance has been disposed and can no longer be used for

  • 0

Error: The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.

I am trying to create a WCF service with Entity Framework (VS 2010, .NET 4). When I run it, I get the above error.

I read something about editing the T4 template, but it appears that it already has

[DataContractAttribute(IsReference=true)]
public partial class Person : EntityObject

and

   [DataMemberAttribute()]
        public global::System.Int32 ID
        {
            get
            {
                return _ID;
            }

I am not sure what the difference is between

[DataMemberAttribute()] and [DataMember] 

or

[DataContractAttribute(IsReference=true)] and [DataContract] 

either.

 public Person GetPersonByID(int id)
        {
            using (var ctx = new MyEntities())
            {
                return (from p in ctx.Person
                        where  p.ID == id
                        select p).FirstOrDefault();
            }
        }

How does WCF and EF work together, properly?

  • 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-16T09:10:57+00:00Added an answer on May 16, 2026 at 9:10 am

    Do you have navigation properties in your Person class? Did you disable lazy loading? Otherwise it will probably try to load content for navigation properties during serialization and it fails because of closed context.

    To your other questions:

    [DataMemberAttribute()] and [DataMember] are same. It is just shorter name.

    [DataContractAttribute(IsReference=true)] and [DataContract] are not same. IsRefrence allows tracking circular references in navigation properties. Without this parameter circular reference causes never ending recursion.

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

Sidebar

Related Questions

An error has occurred while establishing a connection to the server. When connecting to
Parser Error Message: The entry 'SiteSqlServer' has already been added. Source Error: Line 23:
The error I'm getting: in /Users/robert/Documents/funWithFrameworks/build/Debug-iphonesimulator/funWithFrameworks.framework/funWithFrameworks, can't link with a main executable Cliff notes:
Compiler error CS0283 indicates that only the basic POD types (as well as strings,
Came across this error today. Wondering if anyone can tell me what it means:
Error message: fatal: git checkout: updating paths is incompatible with switching branches/forcing How to
This error just started popping up all over our site. Permission denied to call
This error seems to just pop up now and again. It is not restricted
This error message appears on a colleague's machine when he tries to launch a
Fatal error: Allowed memory size of 31457280 bytes exhausted (tried to allocate 9828 bytes).

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.