When I use Entity Framework Core and seed data with migration, I have this error:
The property 'BookId' on entity type 'Library' has a temporary value. Either set a permanent value explicitly or ensure that the database is configured to generate values for this property.
The message means that you have given a value for your key that did not exist if you have dependencies with ForeignKey.
I got the same exception when I had unique index, AddRange failed on unique index and then inside catch exception block was try to remove whole inserted collection. (Not my code, but I had to fix it :-) )
Code sample (simplified):
try {
context.AddRange(users); // List<User>, has property List<Contact>
context.SaveChanges(); // throws exception on unique index
} catch (Exception ex) {
context.RemoveRange(users); // this throws exception "The property 'UserID' on entity type 'Contact' has a temporary value"
throw;
}