TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
36
1.3k
Entity framework c# error on updating a record
May 21 2020 1:09 AM
I am getting the error "
The relationship between the two objects cannot be defined because they are attached to different ObjectContext objects.
" when updating the
Permission
record with
UserRoles
navigation.
var permission = _permissionService.GetPermissionRecordBySystemName(permissionSystemName);
if (permission != null)
{
var userRole = _userService.GetUserRoleById(roleId);
if (permission.UserRoles.Contains(userRole))
{
permission.UserRoles.Remove(userRole);
}
else
{
permission.UserRoles.Add(userRole);
}
_permissionService.Update(permission); // Error at this line
}
I have used UnityContainer and repository pattern.
Reply
Answers (
2
)
Can someone explain Application.DoEvents() with example
Serial port COM name is not same when I remove and plug USB