title: What is the best way to check if related entity exists in EntityFramework
body: <p>I have two entities with one-to-zero-or-one relation: <code>Version</code> and <code>ChangeLog</code>. The second one stores file with changelog (for example 'ReadMe.html'). </p>
  
  <pre><code>public class Version 
  {
      [Key]
      public int Id { get; set; }
      public string Name { get; set; }
      public ChangeLog ChangeLog { get; set; }
  }
  
  public class ChangeLog 
  {
      [Key]
      public int Id { get; set; }
      public string FileName { get; set; }
      public byte[] File { get; set; }
  
      public int VersionId { get; set; }
      public Version Version { get; set; }
  }
  </code></pre>
  
  <p>Code for one-to-one relation:</p>
  
  <pre><code>modelBuilder.Entity&lt;Version&gt;()
              .HasOne(v =&gt; v.ChangeLog)
              .WithOne(c =&gt; c.Version)
              .HasForeignKey&lt;ChangeLog&gt;(c =&gt; c.VersionId);
  </code></pre>
  
  <p>How to check if related entity exists. So for the one-to-many relation I could do things like this <code>Product.Versions.Any()</code>.
  What about one-to-one? Should I use a context <code>context.ChangeLogs.Any(c =&gt; c.VersionId == versionId)</code>?</p>