简体   繁体   中英

How Do I Solve Could not load file or assembly class library "Microsoft.EntityFrameworkCore version = 6.0 in Class Library

I have two problems interlinked with each other.

First, I am creating for the first time a C# class library in .NET 6 that is a data access layer for other apps. I have never created a class library before, so I may not be doing so correctly, however, I have read the Microsoft documentation and think I did it correct. I then referenced the library by adding the dll file by "Add Project Reference".

When I run the application, I get the error:

Could not load file or assembly class library "Microsoft.EntityFrameworkCore version = 6.0 in Class Library.

To clarify, the class library uses Entity Framework Core 6.06.

I have tried deleting the bin and obj folders ad rebuilding, but it doesn't fix the problem. I am not sure what the next step is to solve this.

So after a lot of research, it appears the class library must a made a part of the consuming solution. Otherwise, packages installed in the class library, must also be installed within the consuming application. Once I added these packages, the application worked correctly. Hope this helps someone else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM