Linq to SQL: Why am I getting IDENTITY_INSERT errors?

前端 未结 7 637
长发绾君心
长发绾君心 2020-12-17 02:49

I\'m using Linq to SQL. I have a DataContext against which I am .SubmitChanges()\'ing. There is an error inserting the identity field:

Cannot insert explicit value for         


        
相关标签:
7条回答
  • 2020-12-17 03:44

    My theory of what happened is as follows:

    1. You designed and created the DataBase
    2. You created the DB Context using LINQ TO SQL in visual Studio
    3. You forgot to set the auto-identity to your table
    4. You fixed that by going to your DataBase and setting the auto-identity
    5. But you forgot to recreate/update your LINQ TO SQL DB Context!!!

    :D

    0 讨论(0)
提交回复
热议问题