title: Return list of entities from web service
body: <p>I use an Entity Framework (edmx file) for my model, and I'm using WCF to access my model.
  When  try to return list of an entity data model (example table object), i get an error:</p>
  
  <blockquote>
    <p>The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.</p>
  </blockquote>
  
  <p>Here is my WCF code. IService.cs:</p>
  
  <pre><code>[ServiceContract(CallbackContract = typeof(IPesananCallBack), SessionMode = SessionMode.Required)]
  public interface IPelayanWebService
  {
     [OperationContract]
     List&lt;table&gt; GetAllTables();
  }
  </code></pre>
  
  <p>Service.cs:</p>
  
  <pre><code>public List&lt;table&gt; GetAllTables()
  {
      TableModel model = new TableModel();
      return model.GetAllTables();
  }
  </code></pre>
  
  <p>My code in model:</p>
  
  <pre><code>public List&lt;table&gt; GetAllTables()
  {
      using (restoicdbEntities ent = new restoicdbEntities())
      {
          return ent.table.ToList();
      }
  }
  </code></pre>
  
  <p>in my client, I just call that function, and the error occured.
  Do I have to create my own data contract? Is there anyway to generate the datacontract from the edmx?</p>
  
  <p><strong>Update:</strong>
  This is the generated code from Entity Framework:</p>
  
  <pre><code>[EdmEntityTypeAttribute(NamespaceName="restoicdbModel", Name="table")]
  [Serializable]
  [DataContractAttribute(IsReference=true)]
  public partial class table: EntityObject
  {
      [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
      [DataMemberAttribute()]
      public global::System.Int32 ID_TABLE
      {
          get
          {
              return _ID_TABLE;
          }
          set
          {
              if (_ID_TABLE != value)
              {
                  OnID_TABLEChanging(value);
                  ReportPropertyChanging("ID_TABLE");
                  ID_TABLE = StructuralObject.SetValidValue(value);
                  ReportPropertyChanged("ID_TABLE");
                  OnID_TABLEChanged();
              }
          }
      }
      private global::System.Int32 ID_TABLE;
      partial void OnID_TABLEChanging(global::System.Int32 value);
      partial void OnID_TABLEChanged();
  }
  </code></pre>