Open sonaliee opened 7 years ago
Did you succeed on this? I'm struggled on the same problem. The only way I could made works is adding a new column on table by ADD COLUMN and then creating the REFERECE to another table, but my Character:
using (var con = new SQLiteConnection(DbURL, ConnectionMode))
{
var cmd = con.CreateCommand($"ALTER TABLE Character ADD COLUMN SuperPowerID INTEGER REFERENCES SuperPower(ID);");
cmd.ExecuteNonQuery();
con.Close();
}
But, I can't put a SuperPowerID property on my c# Character class because will throw an error of "duplicate name SuperPowerID".
Also, there's no decorator flag to set to a property to generate and Foreing Key...
So, basically, I think there's no way to automatically generate FKs by decorating Properties...
I need to create a column with foreign key constraint,i have tried to make a table like #this
public class Student { [ForeignKey] public int Id{ get; set; } public string Name { get; set; } } This does not work.