EntityFrameworkCore with SQLite on Xamarin returns System.NotImplemented

entity-framework-core xamarin xamarin.android xamarin.forms

Question

I created Xamarin.Forms Windows UWP and Android application with shared project. To both(UWP and Android) I imported latest stable NuGet packages: Microsoft.EntityFramework version 1.0.0, Microsoft.EntityFramework.Sqlite version 1.0.0 and Xamarin.Forms 2.3.1.114. On shared project I created very simple data model:

public class User
{
  public int Id { get; set; }
  public string UserName { get; set; }
  public string Password { get; set; }
  public string Notes { get; set; }
}

and very simple data context:

public class DataDbContext: DbContext
{
  public static string DatabasePathName;

  public DataDbContext()
      : base()
  {
  }

  public DataDbContext(DbContextOptions options)
      : base(options)
  {
  }

  public DbSet<User> Users { get; set; }

  protected override void OnConfiguring(
    DbContextOptionsBuilder optionsBuilder)
  {
    optionsBuilder.UseSqlite(
      String.Format("Filename={0}", DataDbContext.DatabasePathName));

    base.OnConfiguring(optionsBuilder);
  }
}

(The model uses, according to docs.efproject.net, an implicit definition of the field Id as the key and autoincrement.) Now I initialize database: First set the platform dependent property DatabasePathName and second I'll add three User items to each. I assume that the values of these records will later be read from Resources. At this point, it is just I enter as literals. Records are saved by SaveChanges() method(both UWP and Android returns 3 (saved records)). Now, if I run Windows UWP application and retrive these records by:

List<User> users = dbContext.Users.ToList();

and everything is as it should be. I read the records, so do I get a value which I put in a TextBlock control. But if I use the same code in Xamarin Android Application, this code throws System.NotImplementedException exception. I don't know why. Thank you for the advice.

1
0
8/26/2016 7:44:12 PM

Accepted Answer

There are still a few known issues with Xamarin's implementation of the .NET Standard. See aspnet/Microsoft.Data.Sqlite#255 for more details. We'll keep that issue up-to-date as Xamarin lights up.

0
8/29/2016 4:03:18 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow