Search code examples
c#win-universal-appentity-framework-corewindows-10-universal.net-native

EF7 causes error with .Net native when creating database


I'm using EF7 with SQLite, in a UWP application, here's the situation :

In the Model's OnConfiguring method, I used this code :

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
     var path = Path.Combine(ApplicationData.Current.LocalFolder.Path, _dbFileName);
     optionsBuilder.UseSqlite($"Data Source={path};");
}

The app runs normally in debug mode, and also normally on release mode with .Net native activated but only on a Phone set to English, the app crashes when the phone is set to French.

So I used this code instead :

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
      optionsBuilder.UseSqlite($"Filename={_dbFileName}");
}  

The app now works perfectly on a French and English Devices, but crashes on a Device set to Arabic.

The crash is caused by the following exception :

enter image description here

enter image description here


Solution

  • It looks like you are encountering the conflation of several bugs. First of all, EF Core on UWP has known issues with RC1. These were fixed in RC2 but requires updating your version of UWP Tools in VS to 1.3.1 or greater. See https://github.com/aspnet/Announcements/issues/170. Also, here are some release notes to guide your update from RC1 to RC2. https://docs.efproject.net/en/latest/miscellaneous/rc1-rc2-upgrade.html

    Secondly, the fact that it works in some languages but not other means this is likely a bug in EF Core's support for i18n. You can open issues such as this on https://github.com/aspnet/EntityFramework/issues