Graphdiff is removing entities

entity-framework graphdiff

Question

The following entities are mine:

public class Profile
{
    [Required]
    public string Name { get; set; }

    [Required]
    public string Description { get; set; }

    [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int ID { get; set; }

    public IList<Functionality> Functionalities { get; set; }
}  

and

public class Functionality
{
    [Required]
    public string Name { get; set; }

    [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int ID { get; set; }
}  

When I try the following in my service method, it deletes from the database the functionality objects that aren't on the list of functionalities for profiles:

(...)
var databaseFunctionalities = this
                             .Repository
                             .GetByIds<Functionality>(profile
                                                     .Functionalities
                                                     .ToIdList());
profile.Functionalities.Clear();
profile.Functionalities.AddRange(databaseFunctionalities);

((BaseRepository)this.Repository)
.UpdateGraph(profile,map => map.OwnedCollection(p => p.Functionalities));
this.Repository.SaveChanges();  
(...)  

Any suggestions?
Thanks!

1
1
10/9/2014 8:55:12 AM

Accepted Answer

ZZZ_tmp
3
10/9/2014 12:31:10 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow