Hangfire.EntityFrameworkCore
Hangfire.EntityFrameworkCore copied to clipboard
Make model classes public
Currently the model classes in the project are marked as internal which is normally fine since interaction with the underlying storage should be done with the Hangfire APIs themselves.
However with the addition of EFCore compiled models the generated code that is created from running dotnet ef dbcontext optimize
will have compile errors since it is trying to reference the internal code.
For example, this comes from a sample optimised model
var id = runtimeEntityType.AddProperty(
"Id",
typeof(long),
propertyInfo: typeof(HangfireJob).GetProperty("Id", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(HangfireJob).GetField("<Id>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
valueGenerated: ValueGenerated.OnAdd,
afterSaveBehavior: PropertySaveBehavior.Throw);
The typeof(HangfireJob)
in this case is a compile error since the class is not public.
I propose changing these classes to be public so optimized models will now work. Though it is not really a recommended pattern this will also allow for the use case asked for in #22 to work as well through the dbContext.Set<HangfireJob>()
API.
Happy to make this change and send a PR if you are happy with the concept.