title: In EF6, how to attribute c# model for 1-1 relationship on top of a 1 to many SQL table relationship
body: <p>In Entity Framework 6 code first, what attributes can I add to my C# object model for a 1-1 parent/child relationship while the underlying SQL table relationship is a 1 to many?   </p>
  
  <p>Data is split between data common to all customers and data for a specific customer in SQL Server 2012.</p>
  
  <p>It has three entities, a WarehouseBase base entity, WarehouseCustom customer specific data and a customer entity.</p>
  
  <p>The C# object:</p>
  
  <pre><code>Warehouse
  {
    public Guid ID {get;set;}
    public string Name {get;set;}
    public string Note {get;set;}  //customer specific data
  }
  
  Customer
  { 
    public Guid ID {get;set;}
    public string Name {get;set;}
  }
  </code></pre>
  
  <p>A customer user would use this workflow:</p>
  
  <ol>
  <li>Customer views Warehouse XYZ in browser.  It should return warehouse XYZ shared data (ID, Name) and the customer specific data (Note).</li>
  <li>Customer edits the note and clicks save button</li>
  <li>Note should be saved to database</li>
  </ol>
  
  <p>An admin would edit and save the WarehouseBase data (Name) but not the customer specific data.</p>
  
  <p>SQL tables:</p>
  
  <pre><code>WarehouseBase
    ID : Guid
    Name: Nvarchar (255)
  
  WarehouseCustom
    ID : Guid
    WarehouseBaseID: GUID
    CustomerID : GUID
    Note : Nvarchar (255)
  
  Customer
    ID : Guid
    Name : Nvarchar (255)
  </code></pre>
  
  <p>The system has multiple different concurrent customers using web browser front end connecting to a WebAPI server.  The server uses EF6/C# to acccess a SQL Server.</p>
  
  <p>What attributes can be added to the C# model for this? </p>
  
  <p>Already seen:</p>
  
  <ol>
  <li>One to many relationship: <a href="http://www.entityframeworktutorial.net/code-first/configure-one-to-many-relationship-in-code-first.aspx" rel="nofollow noreferrer">http://www.entityframeworktutorial.net/code-first/configure-one-to-many-relationship-in-code-first.aspx</a></li>
  <li>How to query one to many and load specific child data: <a href="https://stackoverflow.com/questions/43201392/entity-framework-include-filter-child-collection">Entity Framework include filter child collection</a></li>
  </ol>