Entity Framework IDENTITY_INSERT ON doesn't work

后端 未结 2 811
太阳男子
太阳男子 2021-01-19 08:46

I have this code that is supposed to insert the record with identity insert on

using (MCT_DB_ArchiveEntities ent = new MCT_DB_ArchiveEntities())
{
  ent.Exec         


        
2条回答
  •  青春惊慌失措
    2021-01-19 08:57

    It is not supposed to work. It works only if the identity insert is turned on on the same connection as the real insert. In your case two different connections can be used. To make it work you have to maintain your own DB connection and pass it to ObjectContext's constructor.

提交回复
热议问题