I am using EF 4,There is a instead of trigger in the table Service.
The trigger get the value of the serviceTypeid and if the
serviceTypeid is not present in the master table the trigger insert the record in the master table.
Now when i am going to save the records in the Service,
i am getting the error that "Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries."
I googled the issue and found one solution which i used,
the code is something like
Expand|Select|Wrap|Line Numbers
- foreach (Services obService in _lstService)
- {
- entities.Services.AddObject(obService);
- }
- try
- {
- entities.SaveChanges();
- }
- catch (OptimisticConcurrencyException ex)
- {
- entities.Refresh(RefreshMode.ClientWins, entities.Services);
- entities.SaveChanges();
- }
Please help me out to fix this issue