1

I'd like to use composite primary key in many-to-many table relationship. The obj class to create table is:

    [Table("relationsip_tab")]
class HtmlSrcFileRelationship {

    [Column("src_fk"),PrimaryKey]
    public string srcFk { get; set; }

    [Column("file_fk"), PrimaryKey]
    public string fileFk { get; set; }
}

It gave me an error EXCEPTION: SQLite.Net.SQLiteException: table "relationsip_tab" has more than one primary key

I am using Sqlite for Universal Windows Platform,SQLite.Net-PCL and System.Data.SQLite as references. Is there a way to do it?

Vasile Doe
  • 1,674
  • 1
  • 24
  • 40
  • Looks like composite keys are not natively supported. Though there appears to be some workarounds. I found the following link that describes it. http://stackoverflow.com/questions/26623146/how-to-use-sqlite-net-extensions-with-composite-keys – Jarrett Robertson Jun 07 '16 at 17:37

0 Answers0