-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-identityIncludes: Identity and providersIncludes: Identity and providersinvestigatequestion
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I am following the directions for adding a navigation property from ApplicationUser to IdentityUserClaims and keep getting a migration from it that is not empty as these directions state it should be. Am I doing something wrong that's causing changes to the migration?
When I add the Claims navigation property to ApplicationUser the migration creates the following.
public class ApplicationUser : IdentityUser
{
public required string FirstName { get; set; }
public required string LastName { get; set; }
public ICollection<IdentityUserClaim<string>> Claims { get; set; } = new List<IdentityUserClaim<string>>();
}
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ApplicationUserId",
table: "AspNetUserClaims",
type: "TEXT",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_AspNetUserClaims_ApplicationUserId",
table: "AspNetUserClaims",
column: "ApplicationUserId");
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_ApplicationUserId",
table: "AspNetUserClaims",
column: "ApplicationUserId",
principalTable: "AspNetUsers",
principalColumn: "Id");
}
I have also tried adding the following configuration for ApplicationUser but it makes no difference.
public partial class ApplicationUserConfiguration : IEntityTypeConfiguration<ApplicationUser>
{
public void Configure(EntityTypeBuilder<ApplicationUser> builder)
{
builder.Property(p => p.AccountOwnerId);
builder.HasMany(e => e.Claims)
.WithOne()
.HasForeignKey(uc => uc.UserId)
.IsRequired();
}
}
Expected Behavior
The migration created after adding the Claims navigation property is empty as stated in the directions.
Steps To Reproduce
Here is a sample where I have reproduced the problem.
https://github.com/mohaaron/AddClaimsNavigationToAppUserBug
Exceptions (if any)
No response
.NET Version
8.07
Anything else?
No response
Metadata
Metadata
Assignees
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-identityIncludes: Identity and providersIncludes: Identity and providersinvestigatequestion