0

My first ASP.NET Core project.

I'm getting an error

Error CS0234 The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)

Used NuGet to add reference to Entity Framework Core. I believe that should have fixed it, but no luck.

As you can see, the lib is listed under the Dependencies node instead of the usual References node, if that matters. I've compared the csproj files and nothing stands out as obvious why one has a references node and the other doesn't.

Add reference?

9
  • 2
    You appear to have a lot of warnings about various dependencies - have you looked into those warnings? Commented Jul 5, 2019 at 16:21
  • 1
    Maybe you should replace System.Data.Entity with the right namespace Microsoft.EntityFrameworkCore... Commented Jul 5, 2019 at 16:24
  • @BWhite EF Core is added as a NuGet package, not a reference. The namespace is Microsoft.EntityFrameworkCore, not System.Data.Entity. Are you following an EF tutorial instead of an EF Core tutorial perhaps? Remove the explicit reference and change the namespace Commented Jul 5, 2019 at 16:46
  • 1
    Use "Clean solution", and maybe restart VS after cleaning. Commented Jul 5, 2019 at 16:47
  • @Archer this is a question about ASP.NET Core Commented Jul 5, 2019 at 16:47

1 Answer 1

3

In .net the Namespace for EntityFramework is System.Data.Entity, but that changed for EF Core: The right namespace is now Microsoft.EntityFrameworkCore so

using Microsoft.EntityFrameworkCore;

should fix it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.