After I add a new entity to my DbContext, I then retrieve the Sequence generated ID:
Code: Select all
Public Shared Sub UpdateID(ByRef entity As TBLUDACMAP, context As Entities)
Dim LastDate As Date = entity.LAST_OPERATOR_DATE
Dim NewId As Decimal = (From tbl In context.TBLUDACMAPs
Where tbl.LAST_OPERATOR_DATE = LastDate
Select tbl.ID).Single()
entity.ID = NewId
End Sub
Code: Select all
BindingSource.ResetCurrentItem()
and finally if I try to delete this new entity which has the proper Oracle generated ID, I receive a "the property 'ID' is part of the object's key information and cannot be modified" error.
In my Entity Model ID is, of course, set to Entity Key, Nullable = False, and StoreGeneratedPattern = Identity.
Without rebinding my Bindsource, is there a way to make this work?