System data updateexception an error occurred while updating the entries
We will be using the same console application that we created in the previous article, so make sure you have read the previous article before we continue.
We will be adding three methods to the console application: add Customer(), delete Customer() and modify Customer() Create and Add Objects in Entity Framework 4.0 In order to add new objects to the Entity Set, you must create an instance of an Entity type and add the object to the object context.
But it keeps throwing that exception at me, no matter what i choose to try and save.
Well this was an overview of how we can Add, Delete and Update Objects in Entity Framework 4.0.
We have not yet touched upon issues like Concurrency, Foreign Key Dependencies and Cascading Deletes, which is common while dealing with CRUD operations. If you are interested in Entity Framework 4.0, I strongly suggest you to check out my Entity Framework 4.0 article series.
In the code shown above, we are modifying the newly inserted record (‘ID=DNC’) we created in the previous step and then add the ‘CEO’ value for the Contact Title column.
When EF converts your code to a SQL query, it automatically uses parameters to avoid SQL injection attacks.