title: How to create an index for a string property in Entity Framework 7
body: <p>I'm trying to create a code first model for Entity Framework 7. I'm using recently released Visual Studio 2015 Beta and the following versions of EntityFramework packages (snippet from my project.json file):</p>
  
  <pre><code>"EntityFramework.SqlServer": "7.0.0-beta1",
  "EntityFramework.Commands": "7.0.0-beta1",
  </code></pre>
  
  <p>It looks like currently no data annotations are available and I'm using the OnModelCreating override and recently implemented (partly?) migrations to create my model.</p>
  
  <p>For now, primary keys and one-to-one relations work as well as creating indices for integer types. For example:</p>
  
  <pre><code>builder.Entity&lt;Article&gt;(e =&gt;
  {
      e.Key(c =&gt; c.Id);
      e.OneToOne&lt;Category&gt;(c =&gt; c.Category);
      e.Index(c =&gt; c.Time).IsUnique(false);
  });
  </code></pre>
  
  <p>This snippet results in the following migrations code to be generated:</p>
  
  <pre><code>migrationBuilder.CreateTable("Article",
              c =&gt; new
                  {
                      Id = c.String(),
  // ...
                      CategoryIdKey = c.Int(nullable: false),
                      Time = c.DateTime(nullable: false),
  // ...
                 })
              .PrimaryKey("PK_Article", t =&gt; t.Id)
              .UniqueConstraint("UC_Article_CategoryIdKey", t =&gt; t.CategoryIdKey);
  
          migrationBuilder.AddForeignKey("Category", "FK_Category_Article_CategoryId", new[] { "CategoryId" }, "Article", new[] { "CategoryIdKey" }, cascadeDelete: false);
  
          migrationBuilder.CreateIndex("Article", "IX_Article_Time", new[] { "Time" }, isUnique: false, isClustered: false);
  </code></pre>
  
  <p>But when I'm trying to add index to string property, the migration is generated, but when applied is rejected by SQL Server, apparently due to column type being nvarchar(MAX). It seems like the <code>.Required().MaxLength(100)</code> does not force limited string column type generation. And though there is a method to change the column type, I cannot seem to find the way to call it through ModelBuilder:</p>
  
  <pre><code>        builder.Entity&lt;Keyword&gt;(e =&gt;
          {
              e.Key(c =&gt; c.Id);
              e.Property(c =&gt; c.Word).Required().MaxLength(100);
              e.Index(c =&gt; c.Word).IsUnique(true);
          });
  </code></pre>
  
  <p>Resulting migration:</p>
  
  <pre><code>        migrationBuilder.CreateTable("Keyword",
              c =&gt; new
                  {
                      Id = c.Int(nullable: false, identity: true),
                      Word = c.String(nullable: false, maxLength: 100)
                  })
              .PrimaryKey("PK_Keyword", t =&gt; t.Id);
  
          migrationBuilder.CreateIndex("Keyword", "IX_Keyword_Word", new[] { "Word" }, isUnique: true, isClustered: false);
  </code></pre>
  
  <p>Is there a way to create an index on string property in the beta version of EF7?</p>