SQLite "Cannot add PRIMARY KEY column" -Exception

Today I started working with databases. I installed SQLite and SQLite-net. I am programming a Windows 8.1 application using C #.

All I have is the following:

Model:

public class Subject
{
    [PrimaryKey, AutoIncrement]
    public int Id { get; set; }

    public string Name { get; set; }    
}

And OnLaunched-Event in App.Xaml.cs contains:

protected override void OnLaunched(LaunchActivatedEventArgs e)
{
[...]
    // Get a reference to the SQLite database
    DBPath = Path.Combine(
        Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Subjects.s3db");
    // Initialize the database if necessary
    using (var db = new SQLite.SQLiteConnection(DBPath))
    {
        // Create the tables if they don't exist
        db.CreateTable<Subject>();
    }
[...]
}

When I run this, I get the following error after db.CreateTable (); performed:

Unable to add PRIMARY KEY column.

What's going on here? I really would appreciate your help.

Many thanks.

Cheers, FunkyPeanut

+4
source share
3 answers

, , Subject. Id , Subject.

. ( SQLite , , , ) .

+8

. Doing Build/Clean .

0

... , , / , ......

[Table("CopiedTable")]

[Table("MyNewTable")]
0

All Articles