Hello,
It appears that the use of Entity Framework with Code First is broken for Plugins on nopCommerce 4.0+. There are two issues I am facing, one of which I have a workaround. The first issue is that when you run "dotnet ef migrations add initial" it gives an error about not being able to find the deps.json file. This is because the deps.json file gets created inside Presentation/Plugins/Plugin.Name/ but it's looking in Presentation/Plugins/Plugin.Name/netcoreapp2.2/ for the deps.json. If you add the following to the csproj it fixes this problem:
<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
The second problem I am having which I need help on appears to be related to how the ClearPluginAssemblies.proj gets run after build. When you want to run an EF command such as "dotnet ef migrations add initial" on the plugin project, it will build the project which will then run ClearPluginAssemblies.proj which will delete all the dependency DLL's since they exist in Presentation/Nop.Web/bin/Debug/netcoreapp2.2/ which is where they are used when running nopCommerce.
The problem is that dotnet ef commands don't know that and they keep saying missing DLL Nop.Core.DLL. I have tried everything I could find so far on how to make the "dotnet ef" commands look in that folder for dependecy DLL's but nothing has worked so far. The only way I can get dotnet ef commands to work is by deleting the <Target> from csproj that runs ClearPluginAssemblies.proj while running the dotnet ef command and then to put that Target back before I run the project again.
Any assistance on how to get this to work would be great. Thanks!