Please also note that using the the above command fails in Sqlite because the SQL generated is not correct and throws this error: SQLite Error 1: ânear âCONSTRAINTâ: syntax errorâ. the FK gets created correctly in my MS SQL 2019 server.
Yeah SQLite doesnât support adding Foreign Keys Constraints. The recommended solution is to rename the old table, create the new table with all the Foreign Key constraints you need, then copy the data back in.
@bgiromini you are correct, the ForeignKey and Reference attributes currently do not call any path with FOREIGN KEY, so your use of Db.AddForeignKey is correct. I think this is the best approach since how/when/if populating FK row values is a task that generally will be more involved. Weâll take a look at how/if this might be better supported.
My expectation is that it would have to obviously be nullable or it would never work. I am on a project that has spanned a year so requirements changed and I needed to add more references. I had done it a previous migration months ago assuming it created a foreign key but it did not.