Skip to content

Commit ffa3d53

Browse files
Update
1 parent 418eeac commit ffa3d53

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

EssentialCSharp.Web/Areas/Identity/Data/EssentialCSharpWebContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ protected override void OnModelCreating(ModelBuilder builder)
1515
{
1616
base.OnModelCreating(builder);
1717

18+
// EF design-time model building does not infer Identity store options,
19+
// so keep the persisted schema explicit for login/token key lengths.
1820
builder.Entity<IdentityUserLogin<string>>(login =>
1921
{
2022
login.Property(entry => entry.LoginProvider).HasMaxLength(EssentialCSharpWebIdentitySchema.KeyMaxLength);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
namespace EssentialCSharp.Web.Data;
22

3+
/// <summary>
4+
/// Mirrors the ASP.NET Core Identity <c>AddDefaultIdentity</c> default for
5+
/// <c>IdentityOptions.Stores.MaxLengthForKeys</c>.
6+
/// EF model building does not derive that runtime option automatically, so the
7+
/// schema contract keeps the explicit model configuration and runtime options aligned.
8+
/// </summary>
39
public static class EssentialCSharpWebIdentitySchema
410
{
11+
/// <summary>
12+
/// ASP.NET Core Identity defaults login/token key lengths to 128.
13+
/// Source: https://github.com/dotnet/aspnetcore/blob/c4db2306aad327f8c45c546f82625082156f73bb/src/Identity/UI/src/IdentityServiceCollectionUIExtensions.cs#L48-L51
14+
/// Keep this in sync with <c>options.Stores.MaxLengthForKeys</c> and the explicit
15+
/// Identity model configuration so migrations continue to match the existing schema.
16+
/// </summary>
517
public const int KeyMaxLength = 128;
618
}

0 commit comments

Comments
 (0)