title: Calling EF Core HasIndex from F#
body: <p>I'm trying to rewrite a C# EF Core example (similar to <a href="https://docs.microsoft.com/en-us/ef/core/modeling/indexes" rel="nofollow noreferrer">the one in the docs</a>) into F#. I have a problem with <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.metadata.builders.entitytypebuilder-1.hasindex?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev15.query%3FappId%3DDev15IDEF1%26l%3DEN-US%26k%3Dk(Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder%601.HasIndex);k(DevLang-FSharp)%26rd%3Dtrue&amp;view=efcore-2.0" rel="nofollow noreferrer">HasIndex</a>. In C#, the call is <code>HasIndex(b =&gt; b.Isbn)</code>, to create an index on the Isbn column:</p>
  
  <pre><code>public class SampleContext : DbContext
  {
      public DbSet&lt;Book&gt; Books { get; set; }
  
      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;Book&gt;().HasIndex(b =&gt; b.Isbn);
      }
  }
  </code></pre>
  
  <p>Doing the same in F#, <code>HasIndex(fun b -&gt; b.Isbn)</code>, doesn't compile:</p>
  
  <pre><code>type public SampleContext() =
      inherit DbContext()
  
      [&lt;DefaultValue&gt;]
      val mutable books: DbSet&lt;Book&gt;
  
      member x.Books
          with get() = x.books
          and set v = x.books &lt;- v
  
      override __.OnModelCreating(modelBuilder) =
          modelBuilder.Entity&lt;Book&gt;().HasIndex(fun b -&gt; b.Isbn) // doesn't compile
          |&gt; ignore
  </code></pre>
  
  <p>Do I need to use some quotation magic to make this work?</p>
  
  <p>(You can of course use a string, <code>HasIndex("Isbn")</code>, but I'd prefer not to throw compile time checks out the window.)</p>