Answer the question
In order to leave comments, you need to log in
How to update entity in entity framework with one to one relationship?
Hello. Faced the following problem while working with entity framework. There are models:
public class Test
{
[Key]
public int Id { get; set; }
[Required]
public string Title { get; set; }
[Required]
public int CategoryId { get; set; }
public virtual Category Category { get; set; }
[Required]
public virtual TestsDescription TestsDescription { get; set; }
..........
}
public class TestsDescription
{
[Key]
public int Id { get; set; }
..........
}
void IRepositoryForEntity<T>.Update(T entity)
{
............
_db.Entry(entity).State = EntityState.Modified;
}
Answer the question
In order to leave comments, you need to log in
According to MSDN for TestDescription, you also need to change the status to Modified manually.
Alternatively, check out this package: GraphDiff
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question