i get the customerobject by passing the userid and password this step done successfully but when i am trying to update the same customer i have been getting the above error i can't understand what is that error shows we have 2 projects
shopObjects --> this containt he entity framework with business Logic layer we consume this as dll into webapplication that is called shop2010 following is the code used to get and update
#Region "Get an object based on Primary key"
Public Function GetByPrimKey(Of T1 As System.Data.Objects.DataClasses.EntityObject)(ByVal key As EntityKey) As T1 Implements IBase(Of T, TKey).GetByPrimKey
' Using ESEnityContext As EashShopModelEntities = EasyShopContext.GetEasyShopEntityContext()
Try
Dim varIntervalo As New TimeSpan(0, 2, 0)
If DirectCast(ESEnityContext.GetObjectByKey(key), T1) Is Nothing Then
Return Nothing
Else
Return DirectCast(ESEnityContext.GetObjectByKey(key), T1)
End If
Catch ex As Exception
Throw New Exception(ex.Message)
Finally
End Try
' End Using
End Function
#End Region
#Region "Update an entity"
Public Overridable Function Update(ByVal entity As T) As T Implements IBase(Of T, TKey).Update
'Using ESEnityContext As EashShopModelEntities = EasyShopContext.GetEasyShopEntityContext()
Try
If entity IsNot Nothing Then
ESEnityContext.ContextOptions.LazyLoadingEnabled = False
Dim entry As ObjectStateEntry = ESEnityContext.ObjectStateManager.GetObjectStateEntry(entity)
Dim objectstateentry As ObjectStateManager = ESEnityContext.ObjectStateManager
Dim stateentry As ObjectStateEntry = Nothing
Dim ispresent As Boolean = objectstateentry.TryGetObjectStateEntry(DirectCast(entity, IEntityWithKey).EntityKey, stateentry)
If entry.State = EntityState.Modified Then
ESEnityContext.SaveChanges(SaveOptions.AcceptAllChangesAfterSave)
Return entity
Else
Return Nothing
End If
End If
Catch ex As Exception
Throw New Exception(ex.Message)
Finally
End Try
'End Using
End Function
#End Region
i am getting the error at following line
Dim entry As ObjectStateEntry = ESEnityContext.ObjectStateManager.GetObjectStateEntry(entity) in update method
m.koteswarar...
Member
24 Points
27 Posts
The ObjectStateManager does not contain an ObjectStateEntry with a reference to an object of type...
Jan 09, 2013 06:03 AM|LINK
The ObjectStateManager does not contain an ObjectStateEntry with a reference to an object of type 'EasyShopObjects.Customer'.
while update the customerObject i am getting the error can any please describle why this error came
wavemaster
Participant
1289 Points
1127 Posts
Re: The ObjectStateManager does not contain an ObjectStateEntry with a reference to an object of ...
Jan 09, 2013 01:41 PM|LINK
insufficient information
m.koteswarar...
Member
24 Points
27 Posts
Re: The ObjectStateManager does not contain an ObjectStateEntry with a reference to an object of ...
Jan 10, 2013 05:13 AM|LINK
i get the customerobject by passing the userid and password this step done successfully but when i am trying to update the same customer i have been getting the above error i can't understand what is that error shows we have 2 projects
shopObjects --> this containt he entity framework with business Logic layer we consume this as dll into webapplication that is called shop2010 following is the code used to get and update
#Region "Get an object based on Primary key"
Public Function GetByPrimKey(Of T1 As System.Data.Objects.DataClasses.EntityObject)(ByVal key As EntityKey) As T1 Implements IBase(Of T, TKey).GetByPrimKey
' Using ESEnityContext As EashShopModelEntities = EasyShopContext.GetEasyShopEntityContext()
Try
Dim varIntervalo As New TimeSpan(0, 2, 0)
If DirectCast(ESEnityContext.GetObjectByKey(key), T1) Is Nothing Then
Return Nothing
Else
Return DirectCast(ESEnityContext.GetObjectByKey(key), T1)
End If
Catch ex As Exception
Throw New Exception(ex.Message)
Finally
End Try
' End Using
End Function
#End Region
#Region "Update an entity"
Public Overridable Function Update(ByVal entity As T) As T Implements IBase(Of T, TKey).Update
'Using ESEnityContext As EashShopModelEntities = EasyShopContext.GetEasyShopEntityContext()
Try
If entity IsNot Nothing Then
ESEnityContext.ContextOptions.LazyLoadingEnabled = False
Dim entry As ObjectStateEntry = ESEnityContext.ObjectStateManager.GetObjectStateEntry(entity)
Dim objectstateentry As ObjectStateManager = ESEnityContext.ObjectStateManager
Dim stateentry As ObjectStateEntry = Nothing
Dim ispresent As Boolean = objectstateentry.TryGetObjectStateEntry(DirectCast(entity, IEntityWithKey).EntityKey, stateentry)
If entry.State = EntityState.Modified Then
ESEnityContext.SaveChanges(SaveOptions.AcceptAllChangesAfterSave)
Return entity
Else
Return Nothing
End If
End If
Catch ex As Exception
Throw New Exception(ex.Message)
Finally
End Try
'End Using
End Function
#End Region
i am getting the error at following line
Dim entry As ObjectStateEntry = ESEnityContext.ObjectStateManager.GetObjectStateEntry(entity) in update method
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: The ObjectStateManager does not contain an ObjectStateEntry with a reference to an object of ...
Jan 11, 2013 05:57 AM|LINK
Hi,
This error means that you haven't assigned a primary key for the instance. So please make sure that your primary key exists.
Reguards!