Error when you Add New Scaffold Item for ApplicationUser

Here is one that took me a couple of minutes to figure out: if you are using ASP.NET MVC, and you select Add New Scaffold Item on ApplicationUser, you will get the following error:

Severity Code Description Project File Line Column Suppression State
Error CS0453 The type ‘string’ must be a non-nullable value type in order to use it as parameter ‘T’ in the generic type or method ‘Nullable’ INV..NETCoreApp,Version=v1.0

This is caused by the scaffolding assuming that Id fields are integers, that are nullable, when the ApplicationUser Id is a string (which is not nullable). This is a quick 1-minute fix. Just go and remove all of the question marks after the string, For example:

Details(string? id)

Becomes

Details(string id)

Super simple.

Until next time…

Matt

Leave a Reply

Your email address will not be published. Required fields are marked *