title: Update-Database failed: "The index 'IX_Task_UserId' is dependent on column 'UserId'"
body: <p>After adding a <code>[required]</code> annotation to 2 properties on 3 models and running <code>add-migration</code>, I get the following error when running <code>update-database</code>.</p>
  
  <p><code>ALTER TABLE ALTER COLUMN UserId failed because one or more objects access this column.
  The index 'IX_Task_UserId' is dependent on column 'UserId'.</code></p>
  
  <p>My up() migration looks like this:</p>
  
  <pre><code>protected override void Up(MigrationBuilder migrationBuilder)
      {
          migrationBuilder.DropForeignKey(
              name: "FK_TaskList_AspNetUsers_UserId",
              table: "TaskList");
  
          migrationBuilder.DropForeignKey(
              name: "FK_Template_AspNetUsers_UserId",
              table: "Template");
  
          migrationBuilder.DropForeignKey(
              name: "FK_Task_AspNetUsers_UserId",
              table: "Task");
  
          migrationBuilder.AlterColumn&lt;string&gt;(
              name: "UserId",
              table: "Task",
              nullable: false);
  
          migrationBuilder.AlterColumn&lt;string&gt;(
              name: "TaskName",
              table: "Task",
              nullable: false);
  
          migrationBuilder.AlterColumn&lt;string&gt;(
              name: "UserId",
              table: "Template",
              nullable: false);
  
          migrationBuilder.AlterColumn&lt;string&gt;(
              name: "TemplateName",
              table: "Template",
              nullable: false);
  
          migrationBuilder.AlterColumn&lt;string&gt;(
              name: "UserId",
              table: "TaskList",
              nullable: false);
  
          migrationBuilder.AlterColumn&lt;string&gt;(
              name: "ListName",
              table: "TaskList",
              nullable: false);
  
          migrationBuilder.AddForeignKey(
              name: "FK_TaskList_AspNetUsers_UserId",
              table: "TaskList",
              column: "UserId",
              principalTable: "AspNetUsers",
              principalColumn: "Id",
              onDelete: ReferentialAction.Cascade);
  
          migrationBuilder.AddForeignKey(
              name: "FK_Template_AspNetUsers_UserId",
              table: "Template",
              column: "UserId",
              principalTable: "AspNetUsers",
              principalColumn: "Id",
              onDelete: ReferentialAction.Cascade);
  
          migrationBuilder.AddForeignKey(
              name: "FK_Task_AspNetUsers_UserId",
              table: "Task",
              column: "UserId",
              principalTable: "AspNetUsers",
              principalColumn: "Id",
              onDelete: ReferentialAction.Cascade);
      }
  </code></pre>
  
  <p>I'm not sure what index the error refers to, nor do I fully understand why foreign keys are being dropped (again, all I did was make a few properties non-nullable). Thanks for any help.</p>