IdentityUser extension: retarget to .NET 10, NUnit 4, role services and a model test - #2200
Merged
vladimir-pecanac-main merged 3 commits intoSep 19, 2026
Conversation
Retarget both projects from net7.0 to net10.0 and move the six framework packages to 10.0.12. Test stack moves to Microsoft.NET.Test.Sdk 18.10.0, NUnit 4.6.1, NUnit3TestAdapter 6.3.0, NUnit.Analyzers 4.15.0 and coverlet.collector 10.0.1; the existing assertions are constraint-model already and needed no rewrite. Clear the four CS8618 warnings: required on DisplayName, Post.Title and Post.Text, and a collection expression on Posts so the first live test can still construct a user without posts. AddDefaultIdentity registers no RoleManager and no role store, so the AspNetRoles and AspNetUserRoles tables this context creates had nothing driving them. Add .AddRoles<IdentityRole<Guid>>() in Program.cs and in TestServiceCollectionBuilder. Add Services/UserProfileService.RecordSignIn so the article's runtime example has a home in the sample. Regenerate the migration on EF Core 10. The generated Up() is identical to the 2023 file column for column; only the ProductVersion annotation moves, from 7.0.9 to 10.0.12, and the default schema version still creates seven Identity tables with no passkey table. Add ApplicationUserModelTest, which builds the model over Sqlite with no database and asserts the Guid key, the 100 character DisplayName cap and the absence of AspNetUserPasskeys. Both existing tests carry Live in the name, so CI ran zero tests on this folder; these three run under the FullyQualifiedName!~Live filter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Retargets
aspnetcore-features/IdentityUserExtensionto .NET 10 and closes two gaps the sample had.Retarget and packages
net7.0tonet10.0.Microsoft.NET.Test.Sdk18.10.0,NUnit4.6.1,NUnit3TestAdapter6.3.0,NUnit.Analyzers4.15.0,coverlet.collector10.0.1. The existing assertions are already constraint-model, so NUnit 3 to 4 needed no rewrite.Warnings
<Nullable>enable</Nullable>is on in both projects and four properties had no initializer, so the solution built with four CS8618 warnings.DisplayName,Post.TitleandPost.Textare nowrequired;Postsgets a collection expression rather thanrequired, because the first live test constructs a user without posts. The build is clean.Roles
AddDefaultIdentity<ApplicationUser>()routes throughAddIdentityCoreand registers noRoleManager, no role store and the single-generic claims factory, while this context createsAspNetRolesandAspNetUserRoles..AddRoles<IdentityRole<Guid>>()is added inProgram.csand inTestServiceCollectionBuilder.Migration
Regenerated on EF Core 10. The generated
Up()is identical to the 2023 file column for column; only theProductVersionannotation moves, from 7.0.9 to 10.0.12. The default schema version still creates seven Identity tables and no passkey table.Tests
Both existing tests live in
ApplicationUserLiveTestand need a real SQL Server, so CI ran zero tests on this folder under--filter "FullyQualifiedName!~Live"while reporting green.ApplicationUserModelTestbuilds the model over the already-referenced Sqlite provider with no database, and asserts theGuidkey, the 100 characterDisplayNamecap and the absence ofAspNetUserPasskeysat the default schema version. Three tests now run under that filter.Built and tested on SDK 10.0.302 / runtime 10.0.10: 0 errors, 0 warnings, 3 of 3 non-Live tests passing.