title: Using EF Core 3.1 SQLite database in .NET 4.7.2 class library
body: <p>I have included package <code>Microsoft.EntityFrameworkCore.Sqlite</code> (latest 3.1.x version) in a .NET 4.7.2 Project.
  This is the <code>OnConfiguring</code> Method of my <code>DbContext</code>:</p>
  <pre><code>protected override void OnConfiguring(DbContextOptionsBuilder options)
  {
      options.UseSqlite($@&quot;Data Source=D:\MyDb.db&quot;);
  }
  </code></pre>
  <p>I reference the class library from another .NET 4.7.2 project.</p>
  <p>Whenever I try to read from, write to or create the database (like <code>dbContext.Database.EnsureCreated();</code>), I get the following <code>TypeInitializationException</code> on <code>SqliteConnection</code> constructor with the following InnerException:</p>
  <p>Message: <code>The path has an invalid format</code></p>
  <p>StackTrace:</p>
  <pre><code>at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
     at System.IO.Path.InternalGetDirectoryName(String path)
     at SQLitePCL.NativeLibrary.MakePossibilitiesFor(String basename, Assembly assy, Int32 flags, LibSuffix suffix)
     at SQLitePCL.NativeLibrary.MyLoad(String basename, Assembly assy, Int32 flags, Action`1 log)
     at SQLitePCL.NativeLibrary.Load(String libraryName, Assembly assy, Int32 flags)
     at SQLitePCL.Batteries_V2.MakeDynamic(String name, Int32 flags)
     at SQLitePCL.Batteries_V2.DoDynamic_cdecl(String name, Int32 flags)
     at SQLitePCL.Batteries_V2.Init()
  </code></pre>
  <p>I guess path is related to my ConnectionString but I don't see what's wrong with it.</p>
  <p>For testing purposes I have created a .NET 5 Project and refereced the 4.7.2 class library from there. If I call <code>dbContext.Database.EnsureCreated();</code> In this project, it works as expected and the database is created.</p>
  <p>So I guess it is an issues regarding the mix of .NET 4.7.2 and EF Core. But according to <a href="https://docs.microsoft.com/de-de/ef/core/miscellaneous/platforms" rel="nofollow noreferrer">Microsoft Docs</a> EF Core 3.1 should work fine with .NET 4.7.2</p>
  <p>Maybe something with the SQLite Adapter of EF Core?</p>