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

Ask A Question

Stats

  • Questions 496k
  • Answers 496k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Just replace the 'J' by an 'N' and you're almost… May 16, 2026 at 11:41 am
  • Editorial Team
    Editorial Team added an answer You can use preg_split preg_split("/\\s/", str); May 16, 2026 at 11:41 am
  • Editorial Team
    Editorial Team added an answer Use http://codex.wordpress.org/Function_Reference/get_bloginfo May 16, 2026 at 11:41 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm getting a fatal PHP error when trying to execute my script: Using $this
I am getting an error while using the Entity Framework and C#. I am
I have a WCF service that is using a custom UsernamePasswordValidator. The validator needs
I'm trying to use: // this is a BreakHistory class from the ADO.NET Data
Server Error in '/' Application. The model item passed into the dictionary is of
An error occurred at line: 9 in the jsp file: /Test1.jsp The method addURL(String,
I have an error in my first step with Java, so when i try
I'm getting this error: Only parameterless constructors and initializers are supported in LINQ to
i am using ASP.NET MVC and EF and in my controller i am using
protected IEnumerable GetPersonalsData() { // List<Personals> personel; using (FirmaEntities firmactx = new FirmaEntities()) {

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.