An attempt has been made to Attach or Add an entity that is not new, perhaps having been loaded from another DataContext.
I've followed many threads on this error and it would seem my example should work but it doesn't.
public void Update(Bid bid)
{
if (bid.BidID == 0) // new Bid
{
Bid newBid = new Bid();
AutoMapper.Mapper.DynamicMap<Bid, Bid>(bid, newBid);
_dataContext.Bids.InsertOnSubmit(newBid);
}
_dataContext.SubmitChanges();
}
It sure seems like the newBid object is created in the same data context I'm trying to SubmitChanges to and should therefore be properly tracked. One thing that occurred to me was that the newBid object has it's BidID property set to 0. BidID is an identity column in the database. Could there be some problem there? There is currently no record in the table with a BidID of 0.
Thanks.