I'm using Entity Framework in Xamarin Forms that uses sqlite. When I debug Xamarin.Android
, everything is ok, also in debugging Xamarin.iOs with iPhone simulator, it works fine.
My DbContext
is:
public class DB:DbContext
{
// Tables
private readonly string _databasepath;
public DB(string databasepath)
{
_databasepath = databasepath;
Database.EnsureCreated();
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite($"filename={_databasepath}");
}
}
But when I run my project on an iOS device, this exception will thrown at Database.EnsureCreated()
:
The type initializer for 'Microsoft.EntityFrameworkCore.Query.ResultOperators.Internal.TrackingExpressionNode' threw an exception.
What's wrong?