ForeignKeyReferenceAlreadyHasValueException and Combobox

In database I have a table with user information (name, last name, ...). One of the fields are DepartamentID (type - integer) - it's a relationship to another table - Departaments. Departaments table has primary key DepartamentID.
In *.xaml file i've defined a combobox: <ComboBox
Name="comboBox"
DisplayMemberPath="Name"
SelectedValuePath="DepartamentID"
SelectedValue="{Binding DepartamentID}"
IsSynchronizedWithCurrentItem="True"
/>

I have binding a one table entity to comboBox's parent, and to get comboBox items source i use this: comboBox.ItemsSource = db.Departaments.ToList<Departament>(). ComboBox content loads fine and selected element also is correct, but, when I try to choose another item from comboBox, I'm getting ForeignKeyReferenceAlreadyHasValueException. What I should do in this situation?

[959 byte] By [Ctrl-Alt-Del] at [2008-1-8]
# 1

If the reference property (the property that is the association and refers to a Department) is set then you'll get this exception if you assign an inconsistent value to the foreign key property. What I think you want to do is bind the reference property (probably called Department) and not DepartmentID.

MattWarren-MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 2
I would like to change a field "DepartmentID" in "User" table. It's type is integer. In table "Department" I also have "DepartmentID" field (integer), and it is primary key here. I won't do any changes in Department table, i want to set value in "DepartmentID" from "User" table so that it was one from "DepartmentID" from "Department" table. How does it can be done using ComboBox?
Ctrl-Alt-Del at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 3
Has anyone handled this situacion?
Ctrl-Alt-Del at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...

Visual Studio Orcas

Site Classified