In my project, during migration, I want to do some custom SQL work, so I'm referencing Dapper and Dapper.Contrib. When running the migrations however, using dotnet-fm, I get the following error:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --->
System.IO.FileNotFoundException: Could not load file or assembly 'Dapper.Contrib, Version=1.50.5.0, Culture=neutral,
PublicKeyToken=null'. The system cannot find the file specified.
This only happens when running it using dotnet-fm. If I write my own custom tool and migrate from code:
var runner = serviceProvider.GetRequiredService<IMigrationRunner>();
runner.MigrateUp();
It works just fine. Any ideas?
The problem is, that the dotnet-fm tool doesn't know where to find Dapper.Contrib. There are currently three solutions:
dotnet-fm after publishing the program/libraryDapper.Contrib)dotnet fm and use the in-process migrator (as you already did)Just to clarify: The dotnet fm tool operates on an assembly and not on a project. You'd be required to process all references (project references, package references and direct assembly references) and that would be a huge amount of work.
@fubar-coder Thanks for the follow up, and thanks for an awesome library.