title: How to avoid circular dependency in code first entity framework design
body: <p>I am trying to create modular (component based) application.</p>
  
  <p>My scenario is so simple, I have a <code>SalesManagement</code> component which contains <code>Invoice</code>, and I have <code>PartyManagement</code> component which contains <code>Customer</code>,</p>
  
  <p>so far so good, 
  Then I defined a class for Customer as </p>
  
  <pre><code>public class Customer {
     public int ID {get;set;}
     public string Name {get;set;}
  }
  </code></pre>
  
  <p>and Invoice as </p>
  
  <pre><code>public class Invoice {
     public int ID {get;set;}
     public int CustomerID {get;set;}
     public Customer Customer {get;set;}
  }
  </code></pre>
  
  <p>in order to have <code>Customer</code> reference in Invoice I referenced <code>PartyManagement</code> in <code>SalesManagement</code> component</p>
  
  <p>then I tried to add a collection of Invoice under <code>customer</code> as</p>
  
  <pre><code>public class Customer {
     public int ID {get;set;}
     public string Name {get;set;}
     public virtual ICollection&lt;Invoice&gt; Invoices {get;set;}
  }
  </code></pre>
  
  <p>to make it happen I have to reference <code>InvoiceManagement</code> in <code>PartyManagement</code> which makes a circular dependency between assemblies in compile time</p>
  
  <p>Any idea how to resolve this design issue?</p>
  
  <p>p.s If I keep everything in 1 assembly there is no problem, I want to keep them in separate assemblies</p>