title: How to handle F# Option type with Entity Framework Core?
body: <p>I am using EF Core with F# and I have a entity/model that contains option type. However, EF Core doesn't work well with F# <code>Option&lt;T&gt;</code> type. I could use <code>Nullable&lt;T&gt;</code> but it is not very idiomatic in F# and would prefer to stick with <code>Option</code> type.</p>
  <p>I looked into <strong>Value Converter</strong> but documentation says that <code>null</code> cannot be converted using value converter and additionally, it doesn't play well with generated SQL statements, forcing the client-side filtering instead of using SQL clauses.</p>
  <pre><code>namespace Db
  
  open Microsoft.EntityFrameworkCore
  
  open System
  
  [&lt;CLIMutable&gt;]
  type Invitation =
      { Id: Guid
        Code: string
  
        // HOW TO HANDLE OPTION TYPE
        FirstName: string option
        LastName: string option
        Email: string
        GeneratedAt: DateTime }
  
  [&lt;CLIMutable&gt;]
  type User =
      { Id: Guid
        FirstName: string
        LastName: string
        Email: string
        Password: string
        PasswordSalt: string
        PasswordHash: string }
  
  
  type AppContext(opts) =
      inherit DbContext(opts)
  
      [&lt;DefaultValue&gt;]
      val mutable private invitation: DbSet&lt;Invitation&gt;
  
      member x.Invitation
          with get() = x.invitation
          and set v = x.invitation &lt;- v
  
  
      [&lt;DefaultValue&gt;]
      val mutable private user: DbSet&lt;User&gt;
  
      member x.User
          with get() = x.user
          and set v = x.user &lt;- v
  
  
      override _.OnConfiguring (options: DbContextOptionsBuilder) =
          options.UseSnakeCaseNamingConvention()
          |&gt; ignore
  </code></pre>
  <p>Is there any way I can handle this while generating the model with optional value?</p>