huysentruitw / entity-framework-core-mock

Easy Mock wrapper for mocking EFCore5 DbContext and DbSet using Moq or NSubstitute
MIT License
132 stars 24 forks source link

Fix generated key when initial entities have ids #56

Open Kaffeetasse opened 9 months ago

Kaffeetasse commented 9 months ago

I have encountered an Issue, when an int or long key property is used and the MockDbSet has initial Entities with predefined key values.

This PR also includes a test for this case.

My idea was if a new Entity with a Key is added to set the KeyContext Identity value to the provided Key if it is larger than the current one.