Closed jwstevens-ii closed 2 years ago
You might not be mapping all your Primary Keys to properties on your Model. All primary keys need to be mapped to the model, so that they can figure out if they are equal to each other by a unique identifier.
If that's not the case can you provide a gist of it failing so I can replicate what's going wrong?
Can be related to #71
@jwstevensii Please test with the package that was released of AutoMapper.Collection to see if your error if fixed.
hi, we got the same issue and it was as @TylerCarlson1 stated, an issue with our entity mapping to our contracts. Is it possible to improve the codebase to throw a more understandable exception at this point?
Hi, I get the same problem here, we use Owned entities (which don't have keys) and some entities have also composite primary keys, I don't know if this might be a problem...
builder.Services.AddAutoMapper((serviceProvider, config) => {
config.AllowNullCollections = true;
config.AddCollectionMappers();
config.UseEntityFrameworkCoreModel<DB>(serviceProvider);
}, Assembly.GetExecutingAssembly());
I've added AutoMapper.Collection and AutoMapper.Collection.EntityFramework to my project. But I'm getting a null pointer exception:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
My code is:
All of my entities have ID properties and are attributed with [Key]