title: WCF Service with entity framework - error if foreign key
body: <p>I have a problem. Note that I am a beginner and that the answer could be simple...</p>
  
  <p>I Use Visual Studio 2012 and I want to create a WCF Service with Entity Framework to get access to a database. It can be done in 5-10 minutes...</p>
  
  <ul>
  <li><p>I created a simple database with SQL Express (For example : 2 tables : Client and City, with idCity as a foreign key in the Client table)</p></li>
  <li><p>I created a new WCF service</p></li>
  <li>I added an ADO.NET Entity Data Model (.edmx) linked to my database</li>
  <li>I created a method to return all my clients</li>
  </ul>
  
  <p>When I try the method in the WCF Test Client or in a console application, I get a CommunicazionException error.</p>
  
  <p>But it works correctly if I remove the foreign key in my Client table...</p>
  
  <p>My getClients method :</p>
  
  <pre><code>public Client[] GetClients()
  {
      using (ClientEntities context = new ClientEntities ())
      {
          context.Configuration.LazyLoadingEnabled = false;
          return context.Client.ToArray();
      }
  
  }
  </code></pre>
  
  <p>I used the default configuration...</p>
  
  <p>Is the a special way to do it ? (My code is certainly incomplete to do what I want)</p>
  
  <p>In my application, I want to get all the clients and for each of them, display the client name and the city name.</p>
  
  <p>Thanks</p>