title: Sending Entity Framework entities over WCF: how to prevent serialization of navigation fields?
body: <p>I have a problem when sending Entity Framework-generated entities with navigation properties over WCF. I have a <code>Securities</code> database for storing financial data and two tables inside it:</p>
  
  <p><code>Stock : Id, Symbol, CompanyName, ExchangeName</code><br/>
  <code>Option: Id, StockId, OptionType, Strike</code></p>
  
  <p>I created an Entity Framework model for this database. Then I created WCF service which exposes generated <code>Stock</code> and <code>Option</code> EF entities to the clients.</p>
  
  <p>My generated entity <code>Stock</code> has navigation property <code>EntityCollection&lt;Option&gt; Options</code>.
  When trying to return <code>Stock</code> entity from WCF service to the client, I get an <code>SerializationException</code>: WCF cannot serialize <code>Options</code> navigation property because database connection has been already closed.</p>
  
  <p>I can call <code>Options.Load()</code> method when database connection is opened to fill <code>Options</code> property, but what should I do if I don't want to load full object graph for <code>Stock</code> entity?</p>