Reputation: 9298
I'm trying to save a form using Xamarin and SQLite.
I'm trying to create the local db like this:
SQLiteConnection db;
public MoodDatabaseController()
{
db = DependencyService.Get<ISQLite>().GetConnection();
db.CreateTable<MoodEntry>();
}
MoodEntry
public class MoodEntry
{
[PrimaryKey, AutoIncrement]
public int MoodEntryID { get; set; }
[Indexed]
public DateTime EntryDate { get; set; }
...
GetConnection():
public SQLite_Android() { }
public SQLite.SQLiteConnection GetConnection()
{
var sqliteFileName = "myMood.db3";
string documentsPath = System.Environment.GetFolderPath(System.Environment
.SpecialFolder.Personal);
var path = Path.Combine(documentsPath, sqliteFileName);
var conn = new SQLite.SQLiteConnection(path);
return conn;
}
Error: "SQLite.SQLiteException: duplicate column name: MoodEntryID"
How can it already exists if I only defined it once?
EDIT:
https://github.com/lasseedsvik/myMood
EDIT 2:
I also added an empty ctor to avoid that error
Upvotes: 1
Views: 168
Reputation: 9298
Since I noticed I couldnt update Xamarin packages and getting weird output, I redid the whole solution from scratch and updated Xamarin packages and that solved it for me.
Upvotes: 1