HighwayFramework / Highway.Data

The fastest and smoothest way to great architecture
http://hwyfwk.com
MIT License
72 stars 30 forks source link

Develop #131

Closed ericburcham closed 2 years ago

ericburcham commented 2 years ago

This fixes a bug introduced (by me) in v8.0.0-Beta1, which caused ReadonlyDbContext.OnModelCreating to only fire once per domain. This is because OnModelCreating only fires once per custom DbContext derivative. By inheriting from DbContext, rather than having a private instance of it, each final ReadonlyDomainRepository will wind up invoking OnModelCreating.

There are ways around this, primarily by implementing IDbModelCacheKeyProvider, but this approach moves the ReadonlyDataContext back inline with what the original Highway.Data.DataContext does. I prefer this approach for now, and recommended revisiting the inheritance / composition concern for EF Core.

https://stackoverflow.com/questions/33076291/onmodelcreating-is-never-called