title: C# - How to get the directory path of a .NET Standard Library project inside a WPF solution
body: <p>I have a <code>VS2019</code> solution that has a <code>WPF</code> project referencing a <a href="https://docs.microsoft.com/en-us/dotnet/standard/net-standard" rel="nofollow noreferrer">.NET Standard 2.0</a> project included in the same solution. I am using <a href="https://docs.microsoft.com/en-us/ef/core/" rel="nofollow noreferrer">Entity Framework Core</a> on the <code>.NET Standard Library</code> project where the DbContext class is created as follows.</p>
  
  <p>Because the <code>MyDbContext.cs</code> file is inside the Standard Library project, I was expecting <code>AppDomain.CurrentDomain.BaseDirectory</code> directory in the code below to be inside<code>\bin\Debug\</code> of the Standard Library project where <code>MySQLite.db</code> should have been created . But, on the contrary, it's creating the db inside <code>\bin\Debug\</code> of <code>WPF</code> project.</p>
  
  <p><strong>Question</strong>: In the following code how can we make sure the db is created inside Standard Library project's installation directory (bin\Debug) and not inside the startup project `WPF's directory?</p>
  
  <p><strong>Remark</strong>: </p>
  
  <ol>
  <li>Even in <code>WPF</code> project it is not really creating a real SQLite db, it's is just creating a file <code>MySQLite.db</code> with size <code>0kb</code>. And that is probably happening because all the db related files (dbContext, classes, etc) are in Standard Library project.</li>
  <li>And I finally noticed that <code>PM&gt;Update-Database -Project MyStandardLibraryProj</code> NuGet command actually is creating the real MySQLite.db with all the tables etc. at a strange location: <code>C:\Users\MyUserName\.nuget\packages\Microsoft.EntityFrameworkCore.Tools\3.1.4\tools\net461\any\MySQLite.db</code></li>
  </ol>
  
  <p><strong>MyDbContext.cs</strong> file <code>inside .NET Standard Library</code> Project:</p>
  
  <pre><code>……...
  using Microsoft.EntityFrameworkCore;
  …...
  namespace MyStandardLibraryProj
  {
      public class MyDbContext : DbContext
      {
          string sSQLiteDbPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "MySQLiteDb.db");
          public DbSet&lt;MyObject&gt; MyObjects{ get; set; }
  
          protected override void OnConfiguring(DbContextOptionsBuilder options) =&gt; options.UseSqlite($"Data Source = {sSQLiteDbPath}");
      }
  }
  </code></pre>