I am creating an app using Xamarin with SQLite.NET being used for the local database. I am getting the error message "Don't know about Systems.Collections.Generic.List`1" whenever the database attempts to create a student or register table.
Below is the code for the student and register classes, I have tried to use the SQLite.Net Extensions to allow the tables to be created, but get the error both with/without it.
public class Student
{
[PrimaryKey]
public string StudentID { get; set; }
public string Username { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Image { get; set; }
[ManyToMany(typeof(RegStudent))]
public List<Register> Registers { get; set; }
}
public class RegStudent
{
[ForeignKey(typeof(Student))]
public string StudentID { get; set; }
[ForeignKey(typeof(Register))]
public string RegisterID { get; set; }
}
public class Register
{
[PrimaryKey, AutoIncrement]
public string RegisterID { get; set; }
public string Name { get; set; }
public string Type { get; set; }
public string Location { get; set; }
public DateTime Date { get; set; }
public string StartTime { get; set; }
public string EndTime { get; set; }
public Boolean Recurring { get; set; }
[ManyToMany(typeof(RegStudent))]
public ObservableCollection<KeyValuePair<Student, string>> StudentList {get; set;}
}
The connection to the database is made correctly, and the first table is created normally (as it does not contain lists and only strings). I am not sure why this error still occurs even though I have added in the SQLite.Net Extensions code. Below is the code where the tables are created (this is within the constructor for the database):
try
{
//Now that the connection has been made, try to create the tables if they do not already exist.
_connection.CreateTable<User>();
System.Diagnostics.Debug.WriteLine("Created user table!");
_connection.CreateTable<Student>();
System.Diagnostics.Debug.WriteLine("Created student table!");
_connection.CreateTable<Register>();
System.Diagnostics.Debug.WriteLine("Created register table!");
}
Aucun commentaire:
Enregistrer un commentaire