I am using sqlite net extensions library in my xamarin.forms application. I code in my PCL the database code and models.
When I call SQLiteConnection.CreateTable() I get an error
System.NotSupportedException: Don't know about Cigars.Models.Cigar
Smoke is a child of Cigar, it has a ManyToOne relationship. Here are the models:
Smoke
public class Smoke
{
[PrimaryKey]
public int SmokeId { get; set; }
[ForeignKey(typeof(Cigar))]
public int CigarId { get; set; }
public string Notes { get; set; }
public DateTime DateCreated { get; set; }
//why is this not recognized?
[ManyToOne]
public Cigar Cigar { get; set; }
}
Cigar
public class Cigar
{
[PrimaryKey]
public int CigarId { get; set; }
public string Name { get; set; }
public double Length { get; set; }
}
My database call that causes the exception to be thrown:
private SQLiteConnection db;
public Database(string path)
{
db = new SQLiteConnection(path);
db.CreateTable<Cigar>();
db.CreateTable<Smoke>(); //this throws the error
}
Sqlite.Net.SQLiteConnectionwhich requires aISQLitePlatformobject as the first parameter and thusSQLiteNetExtensions.Attributes.ManyToOneAttributewould not be known to that type ofSQLiteConnection. - SushiHangover