title: Xamarin Forms +Entity Framework Core + SQLite - Calling migration on production breaks application
body: <p>First I run the following setup<br/><br/>
  <strong>Xamarin Forms - Entity Framework Core 2.2 - SQLite - Android - DEBUG</strong><br/><br/>
  And everything works fine. The .db file is generated properly and queries are executed on the database.
  Then I prepared the application for production and I changed the DEBUG to RELEASE compiled, and packed into an apk. As installed on the device the application always crashes when calling either <code>Database.Migrate()</code> or <code>Database.EnsureCreated()</code></p>
  
  <p>The scenario is the same on every application I tried. App runs properly in emulator and on the device being in DEBUG mode. App crashes on every Android device when creating the database.</p>
  
  <p>This is the instantiation of the <code>DbContext</code></p>
  
  <pre><code>public ItemContext(DbContextOptions&lt;ItemContext&gt; options)
      : base(options)
  {
      //Database.Migrate();
      Database.EnsureCreated();
  }
  </code></pre>
  
  <p>This is how the constructor is called</p>
  
  <pre><code>public void Load()
  {
      string databasePath = DependencyService.Get&lt;ILocalFileStorageService&gt;().GetDatabaseFilePath("ItemSQLite.db");
  
      string connectionString = $"Filename={databasePath}";
      DbContextOptions&lt;ItemContext&gt; options = new DbContextOptionsBuilder&lt;ItemContext&gt;()
              .UseSqlite(connectionString)
              .Options;
  
      dataService = new DataService(new ItemContext(options));
  }
  </code></pre>
  
  <p>This is how I retrieve the filepath on Android. </p>
  
  <pre><code>public string GetDatabaseFilePath(string fileName)
  {
      string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
      return Path.Combine(path, fileName);
  }
  </code></pre>
  
  <p>When looking on the Android Device Monitor a very long error is displayed
  The beginning is
  <a href="https://i.stack.imgur.com/Tm0Gk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Tm0Gk.png" alt="Error message part 1"></a>
  somewhere later there is the <code>EnsureCreated</code> method listed
  <a href="https://i.stack.imgur.com/EEHS4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EEHS4.png" alt="Error message part 2"></a></p>
  
  <p><strong>The Question: Why is this happening and how to make the application runnable on production?</strong></p>