title: Entity Framework - The object 'PK_AspNetUserTokens' is dependent on column 'UserId'
body: <p>I created a new ASP.NET Core 2 MVC project in VS 2017 (version 15.5), changed user id type from string to Guid (also changed ApplicationUser class name to User), added my models and then</p>
  
  <pre><code>Add-Migration Init
  Update-Database
  </code></pre>
  
  <p>but it generates error and database won't get created.</p>
  
  <pre><code>The object 'PK_AspNetUserTokens' is dependent on column 'UserId'.
  ALTER TABLE ALTER COLUMN UserId failed because one or more objects access this column.
  </code></pre>
  
  <p>Here's my context:</p>
  
  <pre><code>public class ApplicationDbContext : IdentityDbContext&lt;User, IdentityRole&lt;Guid&gt;, Guid&gt;
  {
      public ApplicationDbContext(DbContextOptions&lt;ApplicationDbContext&gt; options)
          : base(options)
      {
      }
  
      public DbSet&lt;TvShow&gt; TvShows { get; set; }
      public DbSet&lt;Episode&gt; Episodes { get; set; }
      public DbSet&lt;Subscription&gt; Subscriptions { get; set; }
      public DbSet&lt;Notification&gt; Notifications { get; set; }
      public DbSet&lt;Genre&gt; Genres { get; set; }
      public DbSet&lt;TvShowGenre&gt; TvShowGenre { get; set; }
  
      protected override void OnModelCreating(ModelBuilder builder)
      {
          base.OnModelCreating(builder);
  
          builder.Entity&lt;Subscription&gt;()
              .HasKey(c =&gt; new { c.TvShowId, c.UserId });
  
          builder.Entity&lt;TvShowGenre&gt;()
              .HasKey(c =&gt; new { c.TvShowId, c.GenreId });
      }
  }
  </code></pre>
  
  <p>Here's my migration class (only up method):</p>
  
  <pre><code>public partial class Init : Migration
  {
      protected override void Up(MigrationBuilder migrationBuilder)
      {
          migrationBuilder.DropIndex(
              name: "UserNameIndex",
              table: "AspNetUsers");
  
          migrationBuilder.DropIndex(
              name: "IX_AspNetUserRoles_UserId",
              table: "AspNetUserRoles");
  
          migrationBuilder.DropIndex(
              name: "RoleNameIndex",
              table: "AspNetRoles");
  
          migrationBuilder.AlterColumn&lt;Guid&gt;(
              name: "UserId",
              table: "AspNetUserTokens",
              nullable: false,
              oldClrType: typeof(string));
  
          migrationBuilder.AlterColumn&lt;Guid&gt;(
              name: "Id",
              table: "AspNetUsers",
              nullable: false,
              oldClrType: typeof(string));
  
          migrationBuilder.AlterColumn&lt;Guid&gt;(
              name: "RoleId",
              table: "AspNetUserRoles",
              nullable: false,
              oldClrType: typeof(string));
  
          migrationBuilder.AlterColumn&lt;Guid&gt;(
              name: "UserId",
              table: "AspNetUserRoles",
              nullable: false,
              oldClrType: typeof(string));
  
          migrationBuilder.AlterColumn&lt;Guid&gt;(
              name: "UserId",
              table: "AspNetUserLogins",
              nullable: false,
              oldClrType: typeof(string));
  
          migrationBuilder.AlterColumn&lt;Guid&gt;(
              name: "UserId",
              table: "AspNetUserClaims",
              nullable: false,
              oldClrType: typeof(string));
  
          migrationBuilder.AlterColumn&lt;Guid&gt;(
              name: "Id",
              table: "AspNetRoles",
              nullable: false,
              oldClrType: typeof(string));
  
          migrationBuilder.AlterColumn&lt;Guid&gt;(
              name: "RoleId",
              table: "AspNetRoleClaims",
              nullable: false,
              oldClrType: typeof(string));
  
          migrationBuilder.CreateTable(
              name: "Genres",
              columns: table =&gt; new
              {
                  Id = table.Column&lt;long&gt;(nullable: false)
                      .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                  Genres = table.Column&lt;int&gt;(nullable: false),
                  IsFirst = table.Column&lt;bool&gt;(nullable: false)
              },
              constraints: table =&gt;
              {
                  table.PrimaryKey("PK_Genres", x =&gt; x.Id);
              });
  
          migrationBuilder.CreateTable(
              name: "Notifications",
              columns: table =&gt; new
              {
                  Id = table.Column&lt;long&gt;(nullable: false)
                      .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                  CreateDate = table.Column&lt;DateTime&gt;(nullable: false),
                  Message = table.Column&lt;string&gt;(nullable: true),
                  Seen = table.Column&lt;bool&gt;(nullable: false),
                  UserId = table.Column&lt;Guid&gt;(nullable: false)
              },
              constraints: table =&gt;
              {
                  table.PrimaryKey("PK_Notifications", x =&gt; x.Id);
                  table.ForeignKey(
                      name: "FK_Notifications_AspNetUsers_UserId",
                      column: x =&gt; x.UserId,
                      principalTable: "AspNetUsers",
                      principalColumn: "Id",
                      onDelete: ReferentialAction.Cascade);
              });
  
          migrationBuilder.CreateTable(
              name: "TvShows",
              columns: table =&gt; new
              {
                  Id = table.Column&lt;long&gt;(nullable: false)
                      .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                  ProductionYear = table.Column&lt;string&gt;(nullable: true),
                  Status = table.Column&lt;int&gt;(nullable: false),
                  Title = table.Column&lt;string&gt;(nullable: true)
              },
              constraints: table =&gt;
              {
                  table.PrimaryKey("PK_TvShows", x =&gt; x.Id);
              });
  
          migrationBuilder.CreateTable(
              name: "Episodes",
              columns: table =&gt; new
              {
                  Id = table.Column&lt;long&gt;(nullable: false)
                      .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                  BroadcastDate = table.Column&lt;DateTime&gt;(nullable: true),
                  Duration = table.Column&lt;TimeSpan&gt;(nullable: true),
                  Number = table.Column&lt;int&gt;(nullable: true),
                  Season = table.Column&lt;string&gt;(nullable: true),
                  Title = table.Column&lt;string&gt;(nullable: true),
                  TvShowId = table.Column&lt;long&gt;(nullable: false)
              },
              constraints: table =&gt;
              {
                  table.PrimaryKey("PK_Episodes", x =&gt; x.Id);
                  table.ForeignKey(
                      name: "FK_Episodes_TvShows_TvShowId",
                      column: x =&gt; x.TvShowId,
                      principalTable: "TvShows",
                      principalColumn: "Id",
                      onDelete: ReferentialAction.Cascade);
              });
  
          migrationBuilder.CreateTable(
              name: "Subscriptions",
              columns: table =&gt; new
              {
                  TvShowId = table.Column&lt;long&gt;(nullable: false),
                  UserId = table.Column&lt;Guid&gt;(nullable: false)
              },
              constraints: table =&gt;
              {
                  table.PrimaryKey("PK_Subscriptions", x =&gt; new { x.TvShowId, x.UserId });
                  table.ForeignKey(
                      name: "FK_Subscriptions_TvShows_TvShowId",
                      column: x =&gt; x.TvShowId,
                      principalTable: "TvShows",
                      principalColumn: "Id",
                      onDelete: ReferentialAction.Cascade);
                  table.ForeignKey(
                      name: "FK_Subscriptions_AspNetUsers_UserId",
                      column: x =&gt; x.UserId,
                      principalTable: "AspNetUsers",
                      principalColumn: "Id",
                      onDelete: ReferentialAction.Cascade);
              });
  
          migrationBuilder.CreateTable(
              name: "TvShowGenre",
              columns: table =&gt; new
              {
                  TvShowId = table.Column&lt;long&gt;(nullable: false),
                  GenreId = table.Column&lt;long&gt;(nullable: false)
              },
              constraints: table =&gt;
              {
                  table.PrimaryKey("PK_TvShowGenre", x =&gt; new { x.TvShowId, x.GenreId });
                  table.ForeignKey(
                      name: "FK_TvShowGenre_Genres_GenreId",
                      column: x =&gt; x.GenreId,
                      principalTable: "Genres",
                      principalColumn: "Id",
                      onDelete: ReferentialAction.Cascade);
                  table.ForeignKey(
                      name: "FK_TvShowGenre_TvShows_TvShowId",
                      column: x =&gt; x.TvShowId,
                      principalTable: "TvShows",
                      principalColumn: "Id",
                      onDelete: ReferentialAction.Cascade);
              });
  
          migrationBuilder.CreateIndex(
              name: "UserNameIndex",
              table: "AspNetUsers",
              column: "NormalizedUserName",
              unique: true,
              filter: "[NormalizedUserName] IS NOT NULL");
  
          migrationBuilder.CreateIndex(
              name: "RoleNameIndex",
              table: "AspNetRoles",
              column: "NormalizedName",
              unique: true,
              filter: "[NormalizedName] IS NOT NULL");
  
          migrationBuilder.CreateIndex(
              name: "IX_Episodes_TvShowId",
              table: "Episodes",
              column: "TvShowId");
  
          migrationBuilder.CreateIndex(
              name: "IX_Notifications_UserId",
              table: "Notifications",
              column: "UserId");
  
          migrationBuilder.CreateIndex(
              name: "IX_Subscriptions_UserId",
              table: "Subscriptions",
              column: "UserId");
  
          migrationBuilder.CreateIndex(
              name: "IX_TvShowGenre_GenreId",
              table: "TvShowGenre",
              column: "GenreId");
  
          migrationBuilder.AddForeignKey(
              name: "FK_AspNetUserTokens_AspNetUsers_UserId",
              table: "AspNetUserTokens",
              column: "UserId",
              principalTable: "AspNetUsers",
              principalColumn: "Id",
              onDelete: ReferentialAction.Cascade);
      }
  }
  </code></pre>