UserId from 128 to 450 characters

Stesvis 1,041 Reputation points
2022-09-29T15:18:03.96+00:00

During a migration from a project built with EF6 to EF Core 6 I noticed that in EF Core the AspNetUsers.Id column is now an nvarchar(450) while before it was an nvarchar(128).

My models have a foreign key to the AspNetUsers table of nvarchar(128) and everything still works as far as I can tell (but I just started rewriting this project in .NET Core).

Should I refactor the AspNet tables and all the foreign keys and change them to 450 characters or will I be just fine keeping them at 128 chars?

Thanks.

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
726 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 51,346 Reputation points
    2022-09-29T15:53:02.57+00:00

    If you're trying to use the built in ASP.NET Identity system then the DB needs to be updated to work with it. You can read about the changes needed here.

    Any of your code or custom DB objects that are FKs to the updated tables need to be adjusted as well. If you don't then you can lose data (or it'll fail) if truncation occurs.

    0 comments No comments