-
-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BulkInsertOrUpdate throws "Cannot update identity column" exception #131
Comments
You should also set var updateByProp = new List<string> { nameof(Model.ModelDate), nameof(Model.EntityId), nameof(Model.EntityTypeId), nameof(Model.DataTypeId) };
var propToExclude = new List<string> { nameof(Model.ModelId) };
var config = new BulkConfig { UpdateByProperties = updateByProp, PropertiesToExclude = propToExclude };
context.BulkInsertOrUpdate(modelList, config); Additinaly you don't need any of the PK config since EF by convention makes Identity column if one is named Id/ID or TableNameId/ID. PS |
That worked, Appreciate the help, Thank you. |
Below code (simulated to show relevant parts) throw "Cannot update identity column 'ModelID'" exception.
Context
Insert/Update code
I also tried below as well based on certain suggestions I saw regarding this topic for Entity framework core - but didn't help
I also tried SetOutputIdentity, KeepIdentity even though it didn't look like related to the issue.
If I do not include UpdateByProperties, it doesn't throw any exception but it doesnt work as expected.
BulkUpdate does nothing while BulkInsertOrUpdate does an insert which is not the expectation.
The text was updated successfully, but these errors were encountered: