title: After the Automapper mapping where objects go to null values
body: <pre><code> public class CreateOrEditOwnerDetailInput : IInputDto
      {
          [Required]
          public OwnerDetailEditDto OwnerDetail { get; set; }
      }
  
      [AutoMap(typeof(OwnerDetail))]
      public class OwnerDetailEditDto
      {
          public const int MaxLength = 50;
          public const int NotesMaxLength = 300;
  
          public int? Id { get; set; }
  
          [Required]
          [MaxLength(MaxLength)]
          public string LastName { get; set; }
  
  
          [Required]
          [MaxLength(MaxLength)]
          public string CompanyName { get; set; }
  
          [Required]
          public OwnerContactDetailDto ContactDetail { get; set; }
  
          [Required]
          public AdditionalAddressDto AdditionalAddress { get; set; }
  
      }
  
  
  
   [Table("IpOwnerDetails")]
      public class OwnerDetail : FullAuditedEntity
      {
          public const int MaxLength = 50;
          public const int NotesMaxLength = 300;
  
          [Required]
          [MaxLength(MaxLength)]
          public virtual string LastName { get; set; }
  
          [Required]
          [MaxLength(MaxLength)]
          public virtual string CompanyName { get; set; }
  
  
          [ForeignKey("AdditionalAddressId")]
          public virtual AdditionalAddress AdditionalAddress { get; set; }
          public virtual int AdditionalAddressId { get; set; }
  
          [ForeignKey("ContactDetailId")]
          public virtual ContactDetail ContactDetail { get; set; }
          public virtual int ContactDetailId { get; set; }
  
  
      }
  
  public class OwnerContactDetailDto : FullAuditedEntityDto
      {
          public const int NumberMaxLength = 20;
  
          [Required]
          [MaxLength(NumberMaxLength)]
          public string MainPhoneNumber { get; set; }
  
          [MaxLength(NumberMaxLength)]
          public string HomePhoneNumber { get; set; }
  
          [Required]
          public ContactDetailType Type { get; set; }
      }
  
    public class AdditionalAddressDto : FullAuditedEntityDto, IOutputDto
      {
          public const int MaxLength = 50;
  
          [Required]
          [MaxLength(MaxLength)]
          public string StreetNumber { get; set; }
  
          [Required]
          public AddressType Type { get; set; }
  
          [Required]
          public int CityId { get; set; }
  
          [Required]
          public int StateId { get; set; }
  
  
      }
  
  Mapper.CreateMap&lt;AdditionalAddress, AdditionalAddressDto&gt;()
                .ReverseMap()
                .ForMember(additionalAddress =&gt; additionalAddress.Id, options =&gt; options.Ignore());
  
              Mapper.CreateMap&lt;ContactDetail, OwnerContactDetailDto&gt;()
                .ReverseMap()
                .ForMember(contactDetail =&gt; contactDetail.Id, options =&gt; options.Ignore());
  
  
   public async Task&lt;int?&gt; EditOwnerDetailAsync(CreateOrEditOwnerDetailInput input)
          {
              var ownerDetail = await _ownerDetailRepository.FirstOrDefaultAsync(p =&gt; p.Id == input.OwnerDetail.Id);
              input.OwnerDetail.MapTo(ownerDetail);//after this it goes null
              await _ownerDetailRepository.UpdateAsync(ownerDetail);
              return input.OwnerDetail.Id;
  
          }
  </code></pre>
  
  <p><strong>Image url :</strong> <a href="http://imgur.com/a/GRdw6" rel="nofollow">http://imgur.com/a/GRdw6</a></p>
  
  <p><strong>Q :</strong> After the mapping inside the <code>EditOwnerDetailAsync</code> method where both <code>AdditionalAddress</code> and  <code>ContactDetail</code> goes to <code>null</code>.Could you tell me why ? Please see the image for more info.</p>
  
  <p><strong>Exception :</strong> </p>
  
  <pre><code>    ERROR 2015-11-20 17:56:18,666 [26   ] lers.Filters.AbpExceptionFilterAttribute - System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while 
  updating the entries. See the inner exception for details. ---&gt; 
  System.Data.Entity.Core.UpdateException: An error occurred while updating the 
  entries. See the inner exception for details. ---&gt; 
  System.Data.SqlClient.SqlException: The UPDATE statement conflicted with the 
  FOREIGN KEY constraint 
  "FK_dbo.IpOwnerDetails_dbo.IpAdditionalAddresses_AdditionalAddressId". The 
  conflict occurred in database "IP", table "dbo.IpAdditionalAddresses", column 'Id'.
      The statement has been terminated.
  </code></pre>
  
  <p><strong>NOTE :</strong> The strange thing here is when I bring the debug pointer back to the <code>input.OwnerDetail.MapTo(ownerDetail);</code> line (2nd time) then it fills data for the <code>AdditionalAddress</code> and <code>ContactDetail</code> objects.How can It be happened ?</p>