radzenhq / radzen-blazor-studio

Sample applications created with Radzen Blazor Studio
https://www.radzen.com/blazor-studio
16 stars 2 forks source link

Extending the Application User / Role models generates an error #96

Closed grewegreg closed 1 year ago

grewegreg commented 1 year ago

After extending the Application User and/or Application Role Models, the new migration includes a reference to creating the Foreign Key _FK_AspNetUserTokens_AspNetUsersUserId on the AspNetUserTokens table. The Foreign Key already exists and is created by the Add Security process. This issue occurs in both the Blazor Server and Web Assembly projects.

This is not a huge issue, just wanted to mention that the problem occurs. In the migration file: 00000000000000_CreateIdentitySchema.cs the following exists:

 migrationBuilder.CreateTable(
                name: "AspNetUserTokens",
                columns: table => new
                {
                    UserId = table.Column<string>(nullable: false),
                    LoginProvider = table.Column<string>(nullable: false),
                    Name = table.Column<string>(nullable: false),
                    Value = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
                    table.ForeignKey(
                        name: "FK_AspNetUserTokens_AspNetUsers_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

After extending the models, and creating a new migration, the following exists in the migration file:

UP

migrationBuilder.AddForeignKey(
                name: "FK_AspNetUserTokens_AspNetUsers_UserId",
                table: "AspNetUserTokens",
                column: "UserId",
                principalTable: "AspNetUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

DOWN

 migrationBuilder.DropForeignKey(
                name: "FK_AspNetUserTokens_AspNetUsers_UserId",
                table: "AspNetUserTokens");
akorchev commented 1 year ago

Hi @grewegreg,

Thank you for reporting this issue. We will address it with the next release.

akorchev commented 1 year ago

Should be addressed in 1.4.1.

grewegreg commented 1 year ago

Thank you very much!