Search code examples
c#visual-studiosqlitemergefody-costura

Merge dll's with Costura, Microsoft.Data.Sqlite throws errors and cannot add-migrations etc


I have a project with at least 50 dll's. And I don't what them in the root folder with .exe of application. I am using Fody/Costura to solve this problem.

But... I want to rewrite the entire database to the sqlite. Something that end-user doesn't need to configure and what would be an easy solution for me.

But when is the Costura turned on it cannot allow me instance.Database.Migrate() and a lot of other commands.

https://gyazo.com/4c2adaf6d279c562cee44b096f123ae5

And when I remove that context with from the App.xaml.cs and try to add-migration it writes:

Your startup project 'x' doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again.

When I turn off Costura everything works. But the dll's are in the root folder :( So...

  • Is there any way how to hide the dlls and have sqlite database in a project?
  • Or is there any other alternative to the serverless database? What works with Costura?
  • I have no problem with some dll's in the root folder but don't want them 50.

EDIT: When I call it as the embedded resource the same problem as in the picture.

EmbeddedAssembly.Load("Project.Microsoft.Data.Sqlite.dll", "Microsoft.Data.Sqlite.dll");


Solution

  • duplicated: Using Fody Costura with Entity Framework Core migrations

    quote from the thread:

    Thanks to Tronald for putting me on the right track. For anyone else who comes across this, for me the trick was to exclude all the SQLitePCLRaw DLLs like this:

    <Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
      <Costura >
        <ExcludeAssemblies>
          SQLitePCLRaw.*
        </ExcludeAssemblies>
      </Costura>
    </Weavers>
    

    This solution works on Migrate(), but doesn't work on add-migration xxx It s a little problem... I just uninstall fody every time when I create a new migration. And then install it again.

    If I don't uninstall Fody then add-migration writes:

    Your startup project 'InstaGTO' doesn't reference

    Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again.