Search code examples
windows-10uwpwindows-10-universalentity-framework-corewindows-10-mobile

Critical issue using EF Core on UWP (unable to open database file)


Steps to reproduce

Follow this simple tutorial.

The issue

Start the app either in Debug or Release.

An exception occurs with db.Database.Migrate();.

Exception thrown: 'Microsoft.Data.Sqlite.SqliteException' in Microsoft.Data.Sqlite.dll. Additional information: SQLite Error 14: 'unable to open database file'.

This is the very first step, Migrate() method should create the database if there is not any yet (it also fails with db.Database.EnsureCreated()).

Further technical details

EF Core Tools version: 1.0.0-preview2-final

EF Core Sqlite version: 1.0.0

UniversalWindowsPlatform version: 5.2.2

Visual Studio version: VS 2015 Update 3

Operating system: Windows 10 10586.494


Solution

  • It appears that, although the first-chance exception is thrown, it doesn't actually represent a bug as EF Core handles this and continues execution normally. However, it leads to a misinterpretation (the database is created anyway).

    More info