I was thinking of ways to duplicate existing entities and possibly alter some of its properties. I have read a couple of articles describing how to achieve them by either using reflection or reading the memory stream.
I had an idea though. What if I get a untracked version of the entity (using AsNoTracking) and, alter the properties as needed, and finally adding it the the DBSet. Something like this:
var duplicate = GetUntrackedEntity(); //method that basically gets the untracked entity duplicate.Id = Guid.NewGuid(); db.SomeDBSet.Add(duplicate); db.SaveChanges();
Now my question is, is this approach advisable? I verified that this works but I'm worried that I'm overlooking something.