I am using Entity Framework. I have a table Person that has a foreign key on Table PersonCategory. Person Id is an auto-incremented identity (1,1). Each time i update the person entity the entity framework inserts a row for PersonCategory Table Even if category is found.
I am using Database first design.
class Person
{
public string Name {get;set}
public PersonCategory {get;set;}
}
class PersonCategory
{
public int ID {get;set}
public string Name{get;set;}
}
First you need to attach the existing
PersonCategoryto the context;