How do I temporarily turn off an IDENTITY column in EF Code First?

后端 未结 2 1285
耶瑟儿~
耶瑟儿~ 2020-12-11 06:34

I\'m creating a rewrite of an existing application in EF Code First, but I need to import some of the data from the existing application\'s database. Here\'s the definition

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-11 07:24

    I recently ran into this same issue. In my case, I was using SQL Server CE. Here's a link to my solution:

    Inserting all rows of a DataTable into a SQL Server table, including Id values (scroll down to Edit 2)

    This is basically Diego's solution #1 -- raw ADO.NET. It's not a great solution because you will need to customize the queries to account for any differences in databases, but hopefully it will help solve your problem for the moment.

提交回复
热议问题