I'm trying to make use of .Net Entity Framework Core for my application. Relevant portions from .csproj files are:
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.0" PrivateAssets="All"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0"/>
In my entity classes I'm using the annotations as described in this tutorial. However, my build is failing with errors like:
error CS0246: The type or namespace name 'DatabaseGeneratedAttribute' could not be found (are you missing a using directive or an assembly reference?)
I have included necessary "using" statements in the code. Still the error seems to persist. Any pointers/suggestions what to check for in order to solve this issue will be greatly appreciated.
I'm developing using VS Code on macOS.
Thanks in advance!
After a exploring the API docs for the annotations, I figured that one needs to include the following using statement:
using System.ComponentModel.DataAnnotations.Schema;
The tutorials of .NET Core Entity Framework that I was referring to seems to be misleading as it only had this "using" statement:
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
Hopefully this answer will help someone stuck with this issue.