Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.2.0.0,

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.

like image 588
Tony_Henrich Avatar asked Sep 18 '25 23:09

Tony_Henrich


2 Answers

Following step help you to solve this problem:

  1. Delete all bin and obj folders.
  2. Clean Solution. [Build>Clean Solution].
  3. Rebuild Solution
like image 112
MD. RAKIB HASAN Avatar answered Sep 20 '25 15:09

MD. RAKIB HASAN


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.

like image 27
Jakub Avatar answered Sep 20 '25 15:09

Jakub