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

Add Support for Keys by Convention #12

Closed coryisakson closed 5 years ago

coryisakson commented 5 years ago

I would like to be able to test Entities that use the Id field convention without the [Key] annotation. Currently the code throws an error when the Key attribute is not found.

huysentruitw commented 5 years ago

Thanks for bringing this up. Build >= 1.0.0.21 now contains a fallback to conventional based Id properties, both Id or <EntityClassName>Id can be used.