title: How do you create an optional navigation property?
body: <p>I'm trying to create Code First DB in F# project and I just can't solve this problem. The idea is to create an optional relation and have a navigation property but if I have option property, EF won't create a migration:</p>
  <blockquote>
  <p>The property 'Product.Model' is of type 'Model' which is not supported
  by the current database provider. Either change the property CLR type,
  or ignore the property using the '[NotMapped]' attribute or by using
  'EntityTypeBuilder.Ignore' in 'OnModelCreating'.</p>
  </blockquote>
  <p>If I ignore the property with Fluent API migration is created but it generates extra field and I get this warning:</p>
  <blockquote>
  <p>The foreign key property 'Product.ModelId1' was created in shadow
  state because a conflicting property with the simple name 'ModelId'
  exists in the entity type, but is either not mapped, is already used
  for another relationship, or is incompatible with the associated
  primary key type. See <a href="https://aka.ms/efcore-relationships" rel="nofollow noreferrer">https://aka.ms/efcore-relationships</a> for
  information on mapping relationships in EF Core.</p>
  </blockquote>
  <p>Here is the examples of models:</p>
  <pre><code>type [&lt;Table(&quot;products&quot;)&gt;]
  [&lt;CLIMutable&gt;]
  Product = {
      [&lt;Key&gt;]
      [&lt;Column(&quot;id&quot;)&gt;]
      Id: Guid
  
  
      [&lt;Column(&quot;name&quot;)&gt;]
      [&lt;Required&gt;]
      Name: string
  
      //relations
      [&lt;Column(&quot;model_id&quot;)&gt;]
      ModelId: Guid option
      Model: Model option
  }
  
  and [&lt;Table(&quot;models&quot;)&gt;]
  [&lt;CLIMutable&gt;]
  Model = {
      [&lt;Key&gt;]
      [&lt;Column(&quot;id&quot;)&gt;]
      Id: Guid
  
      [&lt;Column(&quot;name&quot;)&gt;]
      [&lt;Required&gt;]
      Name: string
  
      //relations
      Products: Product seq
  }
  </code></pre>
  <p>Using C#, adding virtual keyword would solve the issue, but is it possible with F#? Or should I use Nullable&lt;&gt; instead?</p>
  <p><strong>UPDATE</strong></p>
  <p>Ok, so the problem seems to be deeper as I can not see any way to create an optional relation in F# way at all! If I remove nav property, the EF keeps generating extra ModelId1 prop. At the moment, the only thing that seems to work for me is removing navigation property at all and using Nullable type for FK.</p>
  <p>Is the only way to achieve my goal is to rewrite the whole DAL with C#?</p>