Search code examples
asp.net-corevisual-studio-2017nugetnuget-package

type or namespace name 'DataAnnotations' does not exist in the namespace 'System.ComponentModel'


While I added the Nuget packages System.ComponentModel.AnnotationsI am getting the error

type or namespace name 'DataAnnotations' does not exist in the namespace 'System.ComponentModel'

What happened is that I openend an old ASP.NET Core 1.0 project from a book sample and VS17 upgraded it. Then off course I got a lot of warnings from the VS17 in the NuGet dependencies. So I converted the project to Core 2.1 and updated all NuGet dependencies.

But now it complains about the attributes.

Any idea ?

enter image description here


Solution

  • Ok, so a bypass to this issue was to run in the command of the project root dotnet restore after VisualStudio did his conversion thing.

    This solved the issue without having to convert to .NET core 2.0 or higher.