I am trying to implement custom tables to store users / roles, etc. in the SQL server database using Entity framework 6.
I created a basic DbContext that comes from IdentityDbContext
public class MainContext : IdentityDbContext<ApplicationUser> { public MainContext() : base("name=Main") { } public static MainContext Create() { return new MainContext(); } }
I also have a custom class that inherits IdentityUser
public class ServiceUser : IdentityUser{ }
In ConfigureAuth, the defualt code was:
public void ConfigureAuth(IAppBuilder app) { app.CreatePerOwinContext(ApplicationDbContext.Create); app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create); app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create); .. }
I want to use my MainContext here instead of ApplicationDBContext when I try the following
app.CreatePerOwinContext(MainContext.Create());
I get an error
'Type arguments for the Owin.AppBuilderExtensions.CreatePerOwinContext (Owin.IAppBuilder, System.Func)' method cannot be taken out of use. Try to specify the type arguments explicitly.
Given that the default ApplicationDbContext looks like this:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> { public ApplicationDbContext() : base("Main", throwIfV1Schema: false) { } public static ApplicationDbContext Create() { return new ApplicationDbContext(); } }
I do not see what could be causing this error?
keitn source share