Home

EF DbContext Connection (Linq to Entity)

Hi,
I have a .Net Framework 4.7 solution holds my DbContext and models.

I used LINQPad 5 to query my db (linq to entity) without any problems. Now I want to do the same in the new version LINQPad 6.

But since I cannot use an assembly the targets .NETFramework 4.7 I have to work around it like this:

The scenario like this:
I want to use my old models and context in a .net core 3.1 project so I need to create the context and entity classes for an existing database in Entity Framework Core by doing reverse engineering using the Scaffold-DbContext command (which will generate the models and the context), until this point every thing works as it should and I can run the new solution and query the database.

When I try to add a new connection using "Entity Framework Core (2.x, 3.x, 5.x)" and point to the generated dll from my Core 3.1 solution, linqPad will try to download NuGet packages

But it fails to do that:

and

Comments

  • That's strange. Is there anything in the folder %userprofile%.nuget\packages\system.globalization\4.3.0?

    Perhaps try deleting that folder and see what happens.

    Also, did you create clean .NET Core 3.1 solution? I don't think it should require all those packages.

    Also note that it might be better to target .NET 5.

  • Deleting the folder solved the problem :)

    "I don't think it should require all those packages."
    In order to make my solution build after using the Scaffold-DbContext, I had to install the following packages:
    Microsoft.EntityFrameworkCore
    Microsoft.EntityFrameworkCore.SqlServer
    One of then required those packages actually.

    Thank you so much for the speedy reply.

Sign In or Register to comment.