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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s