question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Migrations Bundle needs help finding SQLIte on MacOS

See original GitHub issue

Some of this was detailed in #19693. But at this point it deserves its own issue.

When executing ./bundle that was targetting SQLite, I got the error: "System.DllNotFoundException: Unable to load shared library ‘e_sqlite3’ or one of its dependencies. "

I had this problem on two MacBooks (Big Sur) in VS Code. With the same project in VS Code on Windows , bundle succeeded.

I did a lot of testing and reading.

These two issues were useful reads and triggered the idea that finally led me to success although it is a HACK.

  1. https://github.com/natemcmaster/DotNetCorePlugins/issues/84
  2. https://github.com/natemcmaster/DotNetCorePlugins/issues/214

What ultimately worked was copying the osx/64 runtime file (in bin/debug /runtimes) into the same file path as bundle.exe.

Here you can see where bundle failed (before I copied the file) and then succeeded after I copied the file.

(Ignore the project name I was just reusing an existing project 😃 )

2021-08-10_20-14-20

Obviously it’s a hack but I don’t know my way around this well enough to take this info and come up with the real problem and thereby a proper solution.

Include stack traces

➜  CosmosProviderSample git:(removeowned) ✗ ./bundle
System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.
 ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.DllNotFoundException: Unable to load shared library 'e_sqlite3' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libe_sqlite3, 1): image not found
   at System.Runtime.InteropServices.NativeLibrary.LoadByName(String libraryName, QCallAssembly callingAssembly, Boolean hasDllImportSearchPathFlag, UInt32 dllImportSearchPathFlag, Boolean throwOnError) in System.Private.CoreLib.dll:token 0x6004664+0x41
   at System.Runtime.InteropServices.NativeLibrary.LoadLibraryByName(String libraryName, Assembly assembly, Nullable`1 searchPath, Boolean throwOnError) in System.Private.CoreLib.dll:token 0x6004662+0x7
   at System.Runtime.InteropServices.NativeLibrary.Load(String libraryName, Assembly assembly, Nullable`1 searchPath) in System.Private.CoreLib.dll:token 0x6004669+0xe
   at SQLitePCL.NativeLibrary.Load(String libraryName, Assembly assy, Int32 flags) in SQLitePCLRaw.nativelibrary.dll:token 0x6000001+0x0
   at SQLitePCL.Batteries_V2.MakeDynamic(String name, Int32 flags) in SQLitePCLRaw.batteries_v2.dll:token 0x6000002+0x10
   at SQLitePCL.Batteries_V2.DoDynamic_cdecl(String name, Int32 flags) in SQLitePCLRaw.batteries_v2.dll:token 0x6000003+0x0
   at SQLitePCL.Batteries_V2.Init() in SQLitePCLRaw.batteries_v2.dll:token 0x6000004+0x0
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in System.Private.CoreLib.dll:token 0x6004d94+0x23
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) in System.Private.CoreLib.dll:token 0x6004c98+0x0
   at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize() in Microsoft.Data.Sqlite.dll:token 0x60001d8+0x20
   at Microsoft.Data.Sqlite.SqliteConnection..cctor() in Microsoft.Data.Sqlite.dll:token 0x60000a1+0x0
   --- End of inner exception stack trace ---
   at Microsoft.Data.Sqlite.SqliteConnection..ctor(String connectionString) in Microsoft.Data.Sqlite.dll:token 0x60000a3+0x0
   at Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteRelationalConnection.CreateDbConnection() in Microsoft.EntityFrameworkCore.Sqlite.dll:token 0x6000159+0x0
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection() in Microsoft.EntityFrameworkCore.Relational.dll:token 0x6000514+0x25
   at Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggerExtensions.MigrateUsingConnection(IDiagnosticsLogger`1 diagnostics, IMigrator migrator, IRelationalConnection connection) in Microsoft.EntityFrameworkCore.Relational.dll:token 0x6001645+0x10
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration) in Microsoft.EntityFrameworkCore.Relational.dll:token 0x6000fc3+0x0
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType) in Microsoft.EntityFrameworkCore.Design.dll:token 0x6000479+0x2e
   at Microsoft.EntityFrameworkCore.Design.MigrationsBundle.ExecuteInternal(String context, Assembly assembly, Assembly startupAssembly, String[] args, String migration, String connection) in Microsoft.EntityFrameworkCore.Design.dll:token 0x60003da+0x4a
   at Microsoft.EntityFrameworkCore.Design.MigrationsBundle.<>c__DisplayClass0_0.<Execute>b__0(String[] args) in Microsoft.EntityFrameworkCore.Design.dll:token 0x600065e+0x30
   at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args) in Microsoft.EntityFrameworkCore.Design.dll:token 0x6000097+0x100
   at Microsoft.EntityFrameworkCore.Design.MigrationsBundle.Execute(String context, Assembly assembly, Assembly startupAssembly, String[] args) in Microsoft.EntityFrameworkCore.Design.dll:token 0x60003d9+0xe5
The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.

Include provider and version information

EF Core version: 6.0.0-rc.1.21409.2 EF Core Tools version: 6.0.0-rc.1.21409.2 Database provider: Microsoft.EntityFrameworkCore.Sqlite Target framework: .NET 6.0 Operating system: Macos Big Sur IDE: VS Code 1.59.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
julielermancommented, Sep 15, 2021

Is this in a daily build yet? Latest tool package I am getting is 6.0.0-rc.2.21457.19 which isn’t doing the trick. I’m just assuming I have to be more patient. 😃 GOT IT! Yay. Version 6.0.0-rc.2.21465.1 did the trick for me. Thanks for the fix, @bricelam 😃

1reaction
bricelamcommented, Aug 12, 2021

also note, the dbcontext bundle command fails if csproj refs 6.0.0-x but works if i specify daily build version

I think this is because the same NuGet.Config file isn’t being used (because it’s in a different directory) when restoring the temporary bundle project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Entity Framework Core and sqlite: database migration ...
In this article, I'll illustrate how to use the migrations feature of Entity Framework Core (EF Core). This post is a continuation of...
Read more >
Visual Studio Mac Preview Entity Framework SQLite add ...
But when I execute dotnet ef migrations add init I get the following error. No executable found matching command "dotnet-ef". Was anyone able...
Read more >
Entity Framework Core and sqlite: getting started on ...
This article shows how to setup a multiplatform C# console project that uses Entity Framework Core (1.1.2) and SQLite. We will code on...
Read more >
Migrate your database using Entity Framework Core ...
Learn how to use EF Core's new Migration Bundles feature, how to generate bundles, and how to execute them to migrate your databases....
Read more >
Setting up SQL Server on macOS and managing migrations ...
This article covers the basic approach to setting up SQL Server on MacOS and how to manage migrations through the dotnet cli.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found