I'm creating a base C# library for ASP.NET MVC 5 projects for the company I work for, so when we have to share source code, we would include references to Enterprise.Classes library and the original dependencies are not required since this class would integrate all functionality.
For the DbContext, we have created a custom context that inherits from IdentityDbContext, but whenever it is inherited to create new contexts, the Microsoft.AspNet.Identity.EntityFramework Nuget package is required to be installed to work.
So far this is the code for the custom DbContext:
[DbConfigurationType(typeof(EnterpriseDbConfiguration))]
public class EnterpriseDbContext : IdentityDbContext<EnterpriseUser, EnterpriseRole, long, EnterpriseUserLogin,
EnterpriseUserRole, EnterpriseUserClaim>
{
public EnterpriseDbContext(string contextName = "DefaultEnterpriseConnection") : base(contextName)
{
/* Entities, Configurations and stuff */
}
}
And here is an example of the EnterpriseUser class (which would be the IdentityUser class):
public class EnterpriseUser : IdentityUser<long, EnterpriseUserLogin, EnterpriseUserRole, EnterpriseUserClaim>
{
public EnterpriseUser()
{
RegistrationDate = DateTime.Now;
Enabled = true;
}
/* Additional Properties */
}
Here is an example of an inheriting context, when EnterpriseDbContext is marked for inheritance it requires the Microsoft.AspNet.Identity.EntityFramework Nuget package to be installed:
public class InheritedEnterpriseContext : EnterpriseInfrastructure.Data.EnterpriseDbContext
{
}
How can I build the EnterpriseDbContext so when it is inherited it won't require the Nuget package to be installed?
