I'm trying to do a copy of an object in ef-core 2.0. Im using a query that fetches a lot of objects with Include ande then I use the AsNoTracking to tell ef that this is a completly new object.
Im using the default settings and I'm letting the database generate the Ids on insert. But when I use the AsNoTracking-query I still get the id of the original object which gives me an exception on SaveChanges.
SqlException: Cannot insert explicit value for identity column in table 'Plans' when IDENTITY_INSERT is set to OFF.
I dont actually want to change this setting and if i traverse the objects and changes the Id to 0 it works. Is there any way to handle this problem without traversing all the objects?
Is there a better way to do create a copy?