Cannot insert explicit value for identity column in table 'table' when IDENTITY_INSERT is set to OFF

前端 未结 22 1175
我在风中等你
我在风中等你 2020-11-22 13:56

I have the below error when I execute the following script. What is the error about, and how it can be resolved?

Insert table(OperationID,OpDescription,Filte         


        
22条回答
  •  孤街浪徒
    2020-11-22 14:38

    everyone comment about SQL, but what hapend in EntityFramework? I spent reading the whole post and no one solved EF. So after a few days a found solution: EF Core in the context to create the model there is an instruction like this: modelBuilder.Entity(entity => { entity.Property(e => e.Id).ValueGeneratedNever();

    this produces the error too, solution: you have to change by ValueGeneratedOnAdd() and its works!

提交回复
热议问题