0
I have a project where a dropdownlist
is loaded with the following instructions:
var lista = entities.prato.OrderBy(x => x.nome).ToList();
combo.DataTextField = "nome";
combo.DataValueField = "id";
combo.DataSource = lista;
combo.DataBind();
Then I need to retrieve the item from dropdownlist
and use for creating a record, to retrieve the item I use the following line:
ingrediente i = entities.ingrediente.Find (Convert.ToInt32(combo.SelectedItem.Value));
When time save the record as follows:
ingrediente_prato ip = new ingrediente_prato();
ip.prato = (prato)Session["pratoSelecionado"];
ip.ingrediente = i;
entities.ingrediente_prato.Add(ip);
entities.SaveChanges();
the following error is returned:
An Entity Object cannot be referenced by Multiple instances of Ientitychangetracker
Does anyone have any suggestions?
You have to post the entire code !!! the classes also may not even need to retrieve the ingredient!
– novic