In the following code, I don't believe I am changing the foreign key, but I could be wrong. When I run it, I get the exception:
ForeignKeyReferenceAlreadyHasValueException
Here is the code:
UsersModule um = dc.UsersModules.Where(x => x.UserId == IdParam).FirstOrDefault();
int oldModuleId = um.ModuleId;
string oldModule = um.Module.ModuleName;
The error is thrown on the line:
string oldModule = um.Module.ModuleName
I don't know why I am getting this error because I am just trying to store the value of ModuleName into string oldModule, not change um.Module.ModuleName