Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EntityFrameworkCore does not exist in the namespace Microsoft

I am trying to walk through this tutorial here.

https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/intro

However after successfully installing EntityFrameworkCore in the package manager console using the command:

Install-Package Microsoft.EntityFrameworkCore.SqlServer

then running a dotnet restore successfully in the cmd, the project does not register EntityFrameworkCore. In the .csproj file you can see the line

<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />

Unfortunately whenever I add a using statement with Microsoft.EntityFrameworkCore in a file I get the error mentioned in the title. Any idea why this might be happening?

like image 741
RyeGuy Avatar asked Mar 24 '17 20:03

RyeGuy


People also ask

What is Microsoft EntityFrameworkCore?

Entity Framework Core is a modern object-database mapper for . NET. It supports LINQ queries, change tracking, updates, and schema migrations. EF Core works with many databases, including SQL Database (on-premises and Azure), SQLite, MySQL, PostgreSQL, and Azure Cosmos DB.

What is Microsoft EntityFrameworkCore DbUpdateException?

Microsoft. EntityFrameworkCore. DbUpdateException: 'An error occurred while saving the entity changes. See the inner exception for details. '


2 Answers

I solved this problem by:

(1) Right clicking the project in the Solution Explorer

(2) Clicking unload project

(3) Click edit the .csproj and check if there is a Package Reference to EF

(4) Right clicking the project again in the Solution Explorer

(5) Then clicked reload project

Now it recognizes EntityFrameworkCore and there are no more build errors

like image 195
RyeGuy Avatar answered Sep 19 '22 06:09

RyeGuy


In Visual Code:

Ctrl + Shift + P => Restart OmniSharp

like image 43
Valeriy Baditsa Avatar answered Sep 20 '22 06:09

Valeriy Baditsa