Possible Duplicate:
. The An object with the same key already exists in the ObjectStateManagerObjectStateManager cannot track multiple objects with the same key.
I have used Entity Framework with ObjectDataSource for GridView. while i have tried with updatemethod i got the run time error message
An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key.
Here is my aspx file code:
<asp:ObjectDataSource ID="odsCustomerList" runat="server" DataObjectTypeName="EF.POCO.Customer"
TypeName="EF.BusinessLayer.CustomerMaster" SelectMethod="ReadAllCustomer" SortParameterName="sortExpression"
ConflictDetection="CompareAllValues" OldValuesParameterFormatString="orig{0}"
UpdateMethod="UpdateCustomer" DeleteMethod="DeleteCustomer">
</asp:ObjectDataSource>
Here is my Code File of DA Layer
public void UpdateCustomer(Customer customer, Customer origCustomer)
{
try
{
BusinessEntityBase.Entities.Customers.MergeOption = System.Data.Objects.MergeOption.NoTracking;
BusinessEntityBase.Entities.Customers.Attach(origCustomer);
BusinessEntityBase.Entities.ApplyCurrentValues("Customer", customer);
BusinessEntityBase.Entities.SaveChanges();
}
catch (Exception ex)
{
throw ex;
}
}
Is there anyone who can help to sort out this issue ?