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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:03:43+00:00 2026-05-30T20:03:43+00:00

I have a problem when sending Entity Framework-generated entities with navigation properties over WCF.

  • 0

I have a problem when sending Entity Framework-generated entities with navigation properties over WCF. I have a Securities database for storing financial data and two tables inside it:

Stock : Id, Symbol, CompanyName, ExchangeName
Option: Id, StockId, OptionType, Strike

I created an Entity Framework model for this database. Then I created WCF service which exposes generated Stock and Option EF entities to the clients.

My generated entity Stock has navigation property EntityCollection<Option> Options.
When trying to return Stock entity from WCF service to the client, I get an SerializationException: WCF cannot serialize Options navigation property because database connection has been already closed.

I can call Options.Load() method when database connection is opened to fill Options property, but what should I do if I don’t want to load full object graph for Stock entity?

  • 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-30T20:03:43+00:00Added an answer on May 30, 2026 at 8:03 pm

    I’ve fought with this one for a while.

    First, I turned lazy loading off. But I still had problems with cycles in my object graph.
    Then, I put [DataContract(IsReference = true)] tags on all of my entities. That worked, but I still had a lot of performance issues do to a denormalized database.
    Finally, I broke down and make dtos and I use AutoMapper to populate them.

    One of my coworkers told me to do this from the beginning, and I should have just listened to him. Do yourself a favor and don’t make the same mistake that I did.

    Edit
    I forgot to mention that I had issues deserializing entities that has properties of type ICollection<T>. These will deserialize as arrays. Somehow T[] implements ICollection<T> but Add and Remove will throw exceptions. This was another reason to use DTOs.

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

Sidebar

Related Questions

I have problem while sending messages from android to PC. Messages are send when
greetings all i have a problem that when sending an email from the server
I have problem sending emails, i checked the email sending error logs, and I
I have problem with sending objects via TCPClient. At first, I serialize them into
i have problem in sending zip file in network.. all other formats i am
I have a problem sending plain text emails using PHPMailer. I have text that
I have a problem sending images through the PHP mail function. I have used
I have a problem sending email from a linux machine. The application sends several
I'm having a problem sending java.util.Date objects over RMI, to and from machines in
I have a pretty peculiar problem with sending a SMS from the iPhone programmatically,

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.