Error creating SQLite.Net Update "it does not have a PC"

I am using Lync syntax in PCL using Xamarin.

public class settings
{

    [PrimaryKey, AutoIncrement]
    public int ID { get; set; }

    public string user_name { get; set; }
    public string password { get; set; }
    public string server { get; set; }

}

void CreateTables()
{
    database.CreateTable<settings>();
}

void Insert()
{    
     settings s = new settings();
     s.server = "<none>"
     s.user_name = "";
     s.password = "";
     database.Insert(s)
}

void Update()
{
     settings s = database.Table<settings>().FirstOrDefault();
     s.server = server_address.Text;
     s.user_name = user_name.Text;
     s.password = pass.Text;
     database.Update(s)
}

I get "I can’t update the settings: it does not have a PC" when updating, but the insert works fine. I am using Xamarin in PCL referring to SQLite.net. I am new to SQlite and Xamarin, so please be detailed when asking for more.

UPDATE - RESOLVED

The class is in the same namespace as the place where I instantiate the database object. Just adding "Sqlite" to my attribute fixes a problem that is really strange.

[SQLite.PrimaryKey, SQLite.AutoIncrement]
+4
source share

Source: https://habr.com/ru/post/1599331/


All Articles