Skip to content

Conversation

@chris-briddock
Copy link

Alter database schema design for the Social Logins feature.

Summary of the changes (Less than 80 chars):
Add Id primary keys to IdentityUserTokens/Logins for V3 schema

Please see the attached report.

PR Report.md

…serLogins for V3 schema

Added Id primary key field to IdentityUserToken and IdentityUserLogin entities
Updated V3 schema configuration to use Id primary keys with unique indexes instead of composite keys
Made FindTokenAsync obsolete with guidance to use FindTokenByUniqueIndexAsync for V3 schema
Updated UserStoreBase to use FindTokenByUniqueIndexAsync internally for token operations
Modified UserStore and UserOnlyStore implementations to handle V3 schema with proper Id generation
Updated SqlStoreTestBase to verify V3 schema includes Id columns
Added comprehensive integration tests for UserManager with V3 schema
Created UserStoreVersionThreeTest with specific V3 schema validation
Updated DefaultUI sample to use V3 schema configuration
All automated and manual testing passes successfully
This change improves the database schema by using surrogate primary keys with unique indexes,
which provides better performance and aligns with modern database design patterns.
The V3 schema maintains backward compatibility while offering improved data access patterns
Copilot AI review requested due to automatic review settings October 29, 2025 12:15
@github-actions github-actions bot added the area-identity Includes: Identity and providers label Oct 29, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Oct 29, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Docker containerization support for the IdentitySample.DefaultUI project and implements Identity V3 schema changes. The V3 schema introduces Id primary keys for IdentityUserLogin, IdentityUserToken, IdentityUserClaim, and IdentityRoleClaim entities (replacing composite primary keys with unique indexes), and includes comprehensive Docker setup scripts for Windows and Linux.

Key Changes:

  • Added Docker infrastructure with compose, Dockerfile, and startup scripts (bash/batch) for running the sample with SQL Server
  • Implemented V3 schema changes with Id primary keys and unique indexes for UserLogins and UserTokens
  • Added external authentication support (Google) and email sender service to the sample
  • Updated Entity Framework store implementations to support the new V3 schema with FindTokenByUniqueIndexAsync

Reviewed Changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
start.sh / start.cmd Interactive menu-based scripts to manage Docker containers for SQL Server and web app
docker-compose.yml Docker Compose configuration for SQL Server 2022 and ASP.NET Core web application
Dockerfile Multi-stage build for the Identity sample using .NET 10 preview SDK and runtime
appsettings.json Updated connection string to use Docker SQL Server and added Google auth configuration
Startup.cs Configured V3 schema version, added Google authentication provider, and email sender service
IdentityUserLogin.cs / IdentityUserToken.cs / IdentityUserClaim.cs / IdentityRoleClaim.cs Added Id primary key properties (changed from int to TKey for claims)
UserStoreBase.cs Added FindTokenByUniqueIndexAsync method and obsoleted FindTokenAsync
UserStore.cs / UserOnlyStore.cs Implemented FindTokenByUniqueIndexAsync using unique index queries and added Id generation for string keys
IdentityUserContext.cs Updated V3 model configuration to use Id primary keys with unique indexes; V1/V2 now ignore Id property
Test files Added comprehensive tests for V3 schema functionality with tokens and logins
.devcontainer/devcontainer.json Updated to use proper customizations structure for VS Code extensions and settings

/// </summary>
public virtual TKey Id { get; set; } = default!;
/// <summary>
/// Gets or sets the foreign kwy for the user identifier.
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'kwy' to 'key'.

Suggested change
/// Gets or sets the foreign kwy for the user identifier.
/// Gets or sets the foreign key for the user identifier.

Copilot uses AI. Check for mistakes.
- ConnectionStrings__DefaultConnection=Server=sqlserver;Database=IdentitySample_V3;User Id=sa;Password=YourStrong@Passw0rd;TrustServerCertificate=True;MultipleActiveResultSets=true
# Social login credentials (set these in a .env file or here)
- Authentication__Google__ClientId=${GoogleClientId}
- Authentication__Google__ClientSecret={GoogleClientSecret}
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing dollar sign ($) for environment variable interpolation. Should be ${GoogleClientSecret} to match the pattern used for GoogleClientId on line 33.

Copilot uses AI. Check for mistakes.
…serLogins for V3 schema

Added Id primary key field to IdentityUserToken and IdentityUserLogin entities
Updated V3 schema configuration to use Id primary keys with unique indexes instead of composite keys
Made FindTokenAsync obsolete with guidance to use FindTokenByUniqueIndexAsync for V3 schema
Updated UserStoreBase to use FindTokenByUniqueIndexAsync internally for token operations
Modified UserStore and UserOnlyStore implementations to handle V3 schema with proper Id generation
Updated SqlStoreTestBase to verify V3 schema includes Id columns
Added comprehensive integration tests for UserManager with V3 schema
Created UserStoreVersionThreeTest with specific V3 schema validation
Updated DefaultUI sample to use V3 schema configuration
All automated and manual testing passes successfully
This change improves the database schema by using surrogate primary keys with unique indexes,
which provides better performance and aligns with modern database design patterns.
The V3 schema maintains backward compatibility while offering improved data access patterns
@chris-briddock
Copy link
Author

I'm going to close and re-open another because, on linux the Shipped and Unshpped APIs were amended, where it should just be the unshipped. However this did give me an error when only adding to the unshipped?

@dotnet-policy-service dotnet-policy-service bot added this to the 11.0-preview1 milestone Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-identity Includes: Identity and providers community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant