SQLite with Entity Framework

后端 未结 6 2155
闹比i
闹比i 2021-01-30 17:36

I\'m having a problem with primary keys in Entity Framework when using SQLite. SQLite wants an explicit NULL in the VALUES list on an autoincrementing primary key column. I ha

6条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-30 18:25

    I've had the same problem with EF and SQLite. Try checking the second post: http://sqlite.phxsoftware.com/forums/p/1418/6162.aspx

    The cause for my problem was that the autoincrement was added to the database itself, but the entity model was not properly refreshed. So after the refresh, my field looked something like this:

    
    

    (StoreGeneratedPattern="Identity" was added)

    Before the refresh (with the old model), I just tried setting the id property to 0, which worked as well :)

提交回复
热议问题