I am creating a clone of records but getting an error.
Cannot insert duplicate key, although i am using these 2 lines. But still getting error. --> cannot insert duplicate key
entity.Attributes.Remove(entity.LogicalName + "id");
entity.Attributes.Remove("msdyn_name");
service.Create(entity);
Once I use, this additional command no error is coming and all is working good.
entity.Id = Guid.NewGuid();
I just don't understand why is that, also I have read somewhere that creating own guid via code is not good in D365. If i continue with this will it create aproblem in future in my search or any activity in Dynamics.