I am trying to create a new SQLite table in an SQLite database. However, whenever I run the code db.CreateTable<Set>();, I get a System.NotSupportedException. I viewed these other posts:
Xamarin.Forms Sqlite-net NotSupportedException on ManyToOne relationship "Don't know about <model>"
Not my issue. I only have using SQLite; (SQLite-net-pcl), and when I remove that I get an error around SQLiteConnection(dbPath).
SQLite doesn't know about class Also not a problem. Set is public, and contains no static elements.
Error Message:
System.NotSupportedException: Don't know about App1.Models.Set
Code for creating the db:
public static string dbPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.Personal),
"database.db3");
var db = new SQLiteConnection(dbPath);
db.CreateTable<Set>();
db.CreateTable<Card>();
Set class:
using SQLite;
namespace App1.Models
{
[Table("Set")]
public class Set
{
[MaxLength(64)]
public string name { get; set; }
[PrimaryKey]
public string code { get; set; }
public int amount { get; set; }
[MaxLength(24)]
public string plane { get; set; }
public Set(string _name, string _code, int _amount, string _plane)
{
name = _name;
code = _code;
amount = _amount;
plane = _plane;
}
}
}
App1.Models.Setwhere you usedb.CreateTable<Set>();? I created a new project and your code works well on my side.