Entity Framework 4 Error: Unable to update the EntitySet because it has a DefiningQuery

前端 未结 4 1378
臣服心动
臣服心动 2021-01-01 19:23

Okay, here\'s the scenario. I have 3 tables. One called aspnet_Users one called Categories and a linking table called User_Categories. aspnet_Users and Categories both ha

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-01 20:14

    I assume the full exception message is something similar to:

    Unable to update the EntitySet YourTableName because it has a DefiningQuery and no InsertFunction element exists in the ModificationFunctionMapping element to support the current operation.

    This will occur if your DB's table doesn't have a primary key defined.

    Add a primary key to your table (using SQL Server Management Studio or whatever), and update your .edmx model from the database.

提交回复
热议问题