title: Entity Framework - Code First - Multiplicity constraint violated, The role X of the relationship Y has multiplicity 1 or 0..1
body: <p>Using code first (EF 6), I created a 1 parent - 2 child relationship. Property is the parent object and Property Address as a child with 1 or 0..1 relationship. PropertyImage is another child with 1 to many relationship. PropertyImage works fine but the PropertyAddress throws error if I try to eager load .</p>
  
  <p>Actual Error -</p>
  
  <p>Multiplicity constraint violated. 
   The role 'PropertyAddress_Property_Source' of the relationship 'MyAssetTracker.DataLayer.Models.PropertyAddress_Property' has multiplicity 1 or 0..1.</p>
  
  <pre><code>    // Test Function            
  GetProperty()
  {
  Property property;
              using (var repo = new PropertyRepository())
              {
                  property = repo.AllIncluding(a=&gt;a.Images, a=&gt;a.Address).FirstOrDefault(a =&gt; a.Id == testpropertyid);
              }
  }
  
  
  //Property Repository
  public class PropertyRepository : IPropertyRepository
  {
  
  
          public IQueryable&lt;Property&gt; AllIncluding(params Expression&lt;Func&lt;Property, object&gt;&gt;[] includeProperties)
          {
              IQueryable&lt;Property&gt; query = context.Properties;
              foreach (var includeProperty in includeProperties) {
                  query = query.Include(includeProperty);
              }
              return query;
          }
  }
  
  //Property Entity
  public class Property : DomainModelAuditBase, IDomainModelState
      {
          private Address _address;
          private ICollection&lt;Asset&gt; _assets;
          private ICollection&lt;PropertyImage&gt; _images;
  
          public Property()
          {
              _address = new Address();
              _assets = new List&lt;Asset&gt;();
              _images = new List&lt;PropertyImage&gt;();
          }
  
          public Guid Id { get; set; }
          [StringLength(100), Required]
          public string Title { get; set; }
          public bool IsPrimary { get; set; }
          [StringLength(255)]
          public string Description { get; set; }
  
          [NotMapped]
          public State State { get; set; }
  
          public Guid AddressId { get; set; }
          public Guid UserId { get; set; }
  
          public virtual Address Address
          {
              get { return _address; }
              set { _address = value; }
          }
  
          public virtual ICollection&lt;Asset&gt; Assets
          {
              get { return _assets; }
              set { _assets = value; }
          }
  
          public virtual User User { get; set; }
  
          public virtual ICollection&lt;PropertyImage&gt; Images
          {
              get { return _images; }
              set { _images = value; }
          }
      }
  
  //PropertyAddress
  public class Address : DomainModelAuditBase, IDomainModelState
  {
      [Key,ForeignKey("Property")]
      public Guid PropertyId { get; set; }
      [StringLength(255),Required]
      public string AddressLine1 { get; set; }
      [StringLength(255)]
      public string AddressLine2 { get; set; }
      [StringLength(255)]
      public string City { get; set; }
      [StringLength(255)]
      public string StateProvince { get; set; }
      [StringLength(100)]
      public string PostalCode { get; set; }
      [StringLength(100)]
      public string Country { get; set; }
  
      [NotMapped]
      public State State { get; set; }
  
      public virtual Property Property { get; set; }
  
  }
  </code></pre>