Hi,
I have some problem while mapping foreign key in Code first approach for SQLite.
Table:
CREATE TABLE Employees ( [EmployeeId] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, [FirstName] NVARCHAR(20) NOT NULL, [ReportsTo] INTEGER, [Phone] NVARCHAR(24), FOREIGN KEY ([ReportsTo]) REFERENCES "employees" ([EmployeeId]) ON DELETE NO ACTION ON UPDATE NO ACTION )
Class Mapping
public class Employees { [Key] public int EmployeeId { get; set; } public string FirstName { get; set; } public int ReportsTo { get; set; } // [ForeignKey("EmployeeId")] public string Phone { get; set; } }
Error : Object reference not set to an instance of an object.
If I remove ReportTo property mapping in my Employees class it works fine. how to do ForeignKey mapping?
Thanks,