Home > Software engineering >  .Net Core upgrade to 3.1 throwing error for GetType().ShortDisplayName
.Net Core upgrade to 3.1 throwing error for GetType().ShortDisplayName

Time:03-29

I have upgraded my projects from .Net Core 2.2 to .Net Core 3.1. Currently everything is working fine except below error -

Severity Code Description Project File Line Suppression State Error CS1061 'Type' does not contain a definition for 'ShortDisplayName' and no accessible extension method 'ShortDisplayName' accepting a first argument of type 'Type' could be found (are you missing a using directive or an assembly reference?)

Code is as below :

ex.GetType().ShortDisplayName()

I believe there should be some substitute available for ShortDisplayName in 3.1 but don't know how to get it.

Kindly help.

CodePudding user response:

First add package to your project. It's package name described here

dotnet add package Microsoft.EntityFrameworkCore -v 3.1.0

Then, You should add Microsoft.EntityFrameworkCore.Infrastructure as using statement.

CodePudding user response:

Type class has never had a method with this name and if it had, its name would start with Get and be GetShortDisplayName().

The lack of Get strongly suggests that this is a custom extension method that you didn't yet port to your new project.

  • Related