I'm new to Entity framework. I have an application that reads data from xml and stores it in database. 

Reading and inserting of the data is a daily job. 

In Entity Framework, how can I merge the new data if there is new data in the xml with the old data in the same table?

This code inserts new data when its called, which makes allot of duplicate entities. And I don't want that the data stored in db to be changed. 

```
public void MyCustomTypes(string Xml)
{
    XDocument xDoc = XDocument.Parse(Xml);
    List<Category> allCateogries = new List<Category>();

    var db = new MyContext();

    var caq1 = xDoc.Descendants().Where(e => e.Name.LocalName.Contains("FaceAdd")).Elements().Where(n => n.Name.LocalName.Contains("Buildingtype")).Select(v=>v.Value).Distinct().ToList();

    foreach (var x in caq1)
    {
        Category category = new Category
               {
                   Name = x.ToString(),
                   NrOfFaceAdds= getNr(x.ToString(), xDoc)
               };
        allCateogries.Add(category);                  
    }

    db.Categories.AddRange(allCateogries);
    db.SaveChanges();
}

```