title: efcore zero to one relationship cascade from principal
body: <p>in efcore 2.0 I'm trying to figure out how to configure this:</p>
  
  <p>let say I have two table <code>Upload</code> and <code>BlogPost</code> and some more table that save their upload URL into upload. so the <code>upload</code> table doesn't need to have a FK to any other table that wants to save into it</p>
  
  <pre><code>class Upload{
      public int Id{get; set;}
      public string FileName{get;set;}
      public string SavedPath{get; set;}
  }
  
  //but each blog post need to know about its own upload
  class BlogPost{
      public int Id { get; set; }
      public int Content { get; set; }
      public Upload Upload { get; set; }
  }
  </code></pre>
  
  <p>according to <a href="https://docs.microsoft.com/en-us/ef/core/modeling/relationships#definition-of-terms" rel="nofollow noreferrer">this article</a>, any table that holds the FK is the dependant and any table that hold the primary key is the principal.</p>
  
  <p>but in this case, the <code>BlogPost</code> is the principal and <code>Upload</code> is the dependent. if I delete the <code>BlogPost</code> then the upload must delete, not the otherwise.</p>
  
  <pre><code>modelBuilder.Entity&lt;BlogPost&gt;(b=&gt;{
      b.HasOne(bp=&gt;bp.Upload).WithOne().OnDelete(DeleteBehavior.Cascade);
  })
  </code></pre>
  
  <p>according to <code>OnDelete</code> document, it delete the dependant if the the <strong>principal</strong> deleted, that in my case should be <code>BlogPost</code>, but because the Upload is not carrying any FK, efcore apply cascade wrongly. </p>
  
  <p>my question is how do i make the efcore to get the BlogPost as the principal? or how should i approach this kind of scenario? </p>