title: WCF Contracts from Entity Framework?
body: <p>I've been coming up with a lot of dead ends on this question.  Supposedly, .NET 3.5 SP1 has Support for ADO.NET Entity Framework entities in WCF contracts.  But when I look for solid info on it I'm not getting a lot of answers. I found this one snippet on an MSDN thread.  Does anyone have any experience with this?  What happened to the [DataContract]?  Is this all there is to it?  Why is there so little material on this?</p>
  
  <p>This the answer from Tim Mallalieu in Microsoft.</p>
  
  <p>Entity Types that are generated in the Entity Framework are, by default Data Contracts.
  If I were to create a simple model in the Entity Designer like the following:
  The cart Entity Type is by default a DataContract with all properties annotated as data members. We can then use this in a WCF service as follows:</p>
  
  <pre><code>[ServiceContract]
  
  public interface IService1
  
  {
      [OperationContract]
      Cart[] AllCarts();
  }
  
  
  
  public class Service1 : IService1
  
  {
      public Cart[] AllCarts() 
  
      {
          using (MSPetShop4Entities context = new MSPetShop4Entities())
  
          {
              var carts = from c in context.Carts select c;
              return carts.ToArray();
          }
      }
  }
  </code></pre>
  
  <p>As the Entities are DataContracts you can now roll your services as you see fit and send these across the wire. </p>