Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Core 3.1 and Could not load file or assembly System.Data.Entity, Version=4.0.0.0

What Nuget package is System.Data.Entity in?

I am converting a .NET Framework 4.5 app to .NET Core 3.1. In .NET Framework, it is using System.Linq.Dynamic, and the app is crashing when running this code:

var results = report.GroupBy(filter.ID, "it")
                    .Select($"new (it.Key as MainID, it as MyModel)");

With this error message:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified. File name: 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' at System.Linq.Dynamic.ExpressionParser..cctor()

Note: it does compile correctly

thanks

edit: The System.Linq.Dynamic Nuget package is installed.

like image 499
Xaphann Avatar asked Oct 19 '25 09:10

Xaphann


2 Answers

It seems that System.Data.Entity and System.Linq.Dynamic assemblies belongs to .NET Framework. For .NET Core you can try to use System.Linq.Dynamic.Core package, it's compatible with .NET Standard. Its GitHub repo says, that it's .NET core port of the assembly for the .NET 4.0 Dynamic language functionality.

like image 167
Pavel Anikhouski Avatar answered Oct 21 '25 21:10

Pavel Anikhouski


One point I would like to add to @PavelAnikhouski, a very minor change needs to be made to the code. You have to add AsQueryable() to the collection.

var results = report.AsQueryable()
                .GroupBy(filter.ID, "it")
                .Select($"new (it.Key as MainID, it as MyModel)");
like image 39
Xaphann Avatar answered Oct 21 '25 22:10

Xaphann