title: one-to-one-or-zero relation with OneWay CascadeOnDelete
body: <p>I have an entity that includes many different documents with unkown-relations to any entities in my database.</p>
  
  <pre><code>public class Document : BaseEntity
  {
  
      public string Filename { get; set; }
  
      public string MIMEType { get; set; }
      public int? Length { get; set; }
  
      public byte[] Content { get; set; }
  
  }
  </code></pre>
  
  <p>and the codefirst-mapping is: </p>
  
  <pre><code>    public DocumentConfiguration()
      {
          Property(x =&gt; x.Filename).HasMaxLength(300).IsRequired();
          Property(x =&gt; x.MIMEType).HasMaxLength(300).IsRequired();
          Property(x =&gt; x.Length).IsOptional();
          Property(x =&gt; x.Content).IsOptional().HasColumnType("varbinary(max)");
  
  
          ToTable("Document"); 
      }
  </code></pre>
  
  <p>Now I want  an optional relation to document-table in my addressentity like so:</p>
  
  <pre><code>public class Address : BaseEntity
  {
  
      public string Name1 { get; set; }
      public string Name2 { get; set; }
      public string Additional { get; set; }
  
  
      public string Street { get; set; }
      public string HousNr { get; set; }
      public string ZipCode { get; set; }
      public string City { get; set; }
  
      public virtual Document Image { get; set; }
  
  }
  </code></pre>
  
  <p>with the following mapping: </p>
  
  <pre><code>    public AddressConfiguration()
      {
  
          Property(x =&gt; x.Name1).IsRequired().HasMaxLength(250);
          Property(x =&gt; x.Name2).HasMaxLength(250);
          Property(x =&gt; x.Additional).HasMaxLength(250);
  
  
          Property(x =&gt; x.Street).HasMaxLength(250);
          Property(x =&gt; x.HousNr).HasMaxLength(10);
          Property(x =&gt; x.ZipCode).HasMaxLength(10);
          Property(x =&gt; x.City).HasMaxLength(100);
  
  
          HasOptional(x =&gt; x.Image)
              .WithOptionalDependent()
              .Map(map =&gt; map.MapKey("ImageId")).WillCascadeOnDelete();
  
  
          ToTable("Address");
  
      }
  </code></pre>
  
  <p>But it deletes the related address when I delete an image in the document-table.</p>
  
  <p>I would like a OneWay-Deletation from address to document, but not from document to address...?</p>
  
  <p>How can i implement that?</p>
  
  <p>thank you.</p>