title: WCF Serialization and NHibernate Proxy for a Single Entity Reference
body: <p>Suppose there is NHibernate entity "School" with a "Manager" property which references a single entity of type "Person".</p>
  
  <p>To be "WCF ready", Person is decorated with <code>DataContractAtrribute</code>. The Fluent NH mapping for School.Manager is <code>References(s =&gt; s.Manager)</code>.
  When an entity of type "School" is sent to the client by WCF I get an exception with the following message: </p>
  
  <blockquote>
    <p>"Type 'Castle.Proxies.PersonProxy' cannot be ISerializable and have DataContractAttribute attribute"</p>
  </blockquote>
  
  <p>Now, this only happens when referencing a single entity (and not through a collection).
  My workaround is to disable the proxy by adding <code>.Not.LazyLoad()</code> to the <code>References</code> clause.</p>
  
  <p>Did anyone encounter this problem or have any idea how to resolve it?</p>
  
  <p>Thanks,
  Elad</p>