How do I call OnModelCreating
integral-llc opened this issue · comments
Eugen Rata commented
All of me Entities do not use attributes to mark the keys, everything is happening inside OnModelCreating
override method.
i.e.
modelBuilder.Entity<MarketplaceEntity>(entity =>
{
entity.ToTable("Marketplace", "Application");
entity.HasKey(e => e.MarketplaceKey);
});
How to call this method so the keys are properly initialized? As of now, I'm getting an exception saying the entity does not contain any property marked with KeyAttribute
.
thx!
huysentruitw commented
Unfortunately entity configurations like that are currently not supported. As of now, I can't tell how complex it would be to add support for it. However, currently, you can work-around this by passing your own key-factory to the call to CreateDbSetMock
:
dbContextMock.CreateDbSetMock(x => x.MarketPlaces, (e, _) => e.MarketplaceKey, initialEntities);