4

I created a .net core 2.2 project using the AWS Lambda function template. Added a MySQL EntityFramework nuget package. My project targets .NET Core 2.2. I have code which uses DbContext and EF stuff. When I run the app using their lambda test tool, I get this error: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.2.0.0, .....

Using Process Monitor, I can see the app is trying to load Microsoft.EntityFrameworkCore.dll from ...\bin\Debug\netcoreapp2.2\Microsoft.EntityFrameworkCore.dll which doesn't exist.

My question is why aren't any of the supporting assemblies in that folder? The only assembly (.dll file) in the folder is my app's.

Tony_Henrich
  • 42,411
  • 75
  • 239
  • 374

4 Answers4

1

Following step help you to solve this problem:

  1. Delete all bin and obj folders.
  2. Clean Solution. [Build>Clean Solution].
  3. Rebuild Solution
MD. RAKIB HASAN
  • 3,670
  • 4
  • 22
  • 35
1

Try to use some type of Microsoft.EntityFrameworkCore namespace explicitly somewhere in your code. For example:

var _ = new Microsoft.EntityFrameworkCore.DbContextOptionsBuilder();

It sould force the build to copy the assembly to result directory.

Posio
  • 962
  • 4
  • 15
  • I think that is my answer. Now I have an error on system.threading.task.extensions as described at https://stackoverflow.com/questions/60194368/could-not-load-file-or-assembly-system-threading-tasks-extensions-version-4-2 – Kirsten Apr 06 '22 at 10:55
0

I have some ideas. Firstly check, if the folder that you want to refer allows the Visual to have access.

If it do not work, try reinstaling packages through nugget (If I remember correctly I had this same error.). If it shows that its not installed in nugget manager, just install it, even a few times.

Here is the anwser for your question at the end: Where does NuGet put the dll?

cebilon123
  • 551
  • 1
  • 4
  • 7
  • If VS doesn't have access to the folder, it wouldn't be putting any files in there. VS creates that folder. The packages are installed and the solution compiles. – Tony_Henrich Oct 12 '19 at 16:44
0

I had a similar problem, in my case removing the line from the .csproj file helped

<PublishReadyToRun>true</PublishReadyToRun>