New instance you created
ac = new AnswerComment();
not known EF. This is a completely new instance of an object that EF has not previously seen.
You will need to add it to ef.AnswerComments
ef.AnswerComments.Insert(ac);
Also, make sure ChangeTracking is active for ef .
source share