0

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;
        }
    }
}
3
  • The only issue is creating the SET table? If you only create Card table, everything is ok? Commented Dec 11, 2018 at 11:49
  • Card has the same issue. If needed I can post that code as well. Commented Dec 11, 2018 at 12:04
  • Are you missing a reference to App1.Models.Set where you use db.CreateTable<Set>();? I created a new project and your code works well on my side. Commented Dec 13, 2018 at 2:00

1 Answer 1

1

Rename your table. 'SET' is a keyword in SQLite.

You can find all the keywords in SQLite here. https://www.sqlite.org/lang_keywords.html

Sign up to request clarification or add additional context in comments.

1 Comment

I tried this, but it didn't solve the problem. Would be strange as well since I don't have the issue with the Card table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.