title: Refactor many HasColumnAnnotation and IndexAnnotation usages in my schema definition
body: <p>I have many blocks of code that look like the following:</p>
  
  <pre><code>modelBuilder
      .Entity&lt;Foo&gt;()
      .Property(t =&gt; t.X)
      .IsRequired()
      .HasMaxLength(60)
      .HasColumnAnnotation(IndexAnnotation.AnnotationName, new IndexAnnotation(new IndexAttribute("IX_X_Y", 1) { IsUnique = true }));
  
  modelBuilder
      .Entity&lt;Foo&gt;()
      .Property(t =&gt; t.Y)
      .IsRequired()
      .HasColumnAnnotation(IndexAnnotation.AnnotationName, new IndexAnnotation(new IndexAttribute("IX_X_Y", 2) { IsUnique = true }));
  </code></pre>
  
  <p>This block is telling EF, through fluent API, to create a unique index with columns <code>X</code> and <code>Y</code> together, on table <code>Foo</code>.</p>
  
  <p>Another block of code just like that would be this, with columns <code>R</code> and <code>S</code> on table <code>Bar</code>:</p>
  
  <pre><code>modelBuilder
      .Entity&lt;Bar&gt;()
      .Property(t =&gt; t.R)
      .IsRequired()
      .HasMaxLength(60)
      .HasColumnAnnotation(IndexAnnotation.AnnotationName, new IndexAnnotation(new IndexAttribute("IX_R_S", 1) { IsUnique = true }));
  
  modelBuilder
      .Entity&lt;Bar&gt;()
      .Property(t =&gt; t.S)
      .IsRequired()
      .HasColumnAnnotation(IndexAnnotation.AnnotationName, new IndexAnnotation(new IndexAttribute("IX_R_S", 2) { IsUnique = true }));
  </code></pre>
  
  <p>I want to refactor this, so that it ends up looking something like:</p>
  
  <pre><code>CreateCompositeUnique&lt;Foo&gt;(modelBuilder, "IX_X_Y", t =&gt; new {t.X, t.Y});
  CreateCompositeUnique&lt;Bar&gt;(modelBuilder, "IX_R_S", t =&gt; new {t.R, t.S});
  </code></pre>
  
  <p>I was thinking of something like this:</p>
  
  <pre><code>private void CreateCompositeUnique&lt;T&gt;(DbModelBuilder modelBuilder, string indexName, List&lt;Expression&lt;Func&lt;T, byte[]&gt;&gt;&gt; properties)
  { 
      for (int i = 0; i &lt; properties.Count; i++)
      {
          modelBuilder
          .Entity&lt;typeof(T)&gt;()
          .Property(properties[i])
          .IsRequired() 
          .HasMaxLength(60)  // --only when propery is string
          .HasColumnAnnotation(IndexAnnotation.AnnotationName, new IndexAnnotation(new IndexAttribute(indexName, i) { IsUnique = true }));
      }
  }
  </code></pre>
  
  <p>But I have some questions:</p>
  
  <ol>
  <li>Is this a good idea? </li>
  <li>How do I know if the property is string?</li>
  <li>What is the best way to pass the parameters?</li>
  <li>How do I access "T"? I'm getting a compile error at <code>.Entity&lt;typeof(T)&gt;</code></li>
  </ol>