Entity framework update foreign key to null without query and without id of the related entity
问题 Using EF 6.1, I want to set a foreign key to null (break the relation between two entities), without querying for either object first. Preferably, I also don't want to supply the id of the related entity (since that requires adding it to my HTML). My current code doesn't do unnecessary queries, but requires the id of the related entity: public void RemoveCurrentTeacherOfGroup(int groupId, int teacherId) { var group = new Group { Id = groupId }; var teacher = new Teacher { Id = teacherId };