lundi 23 février 2015

How can I combine Identity and Application DataContext classes?

When you create a EF6 project you get an out of the box implimentation of a datacontext specifically for managing your identities:



public class IdentityContext : IdentityDbContext<ApplicationUser>
{
public IdentityContext()
: base("DefaultConntection", throwIfV1Schema: false)
{
}

public static IdentityContext Create()
{
return new IdentityContext();
}
}


Being a bit pedantic myself I would like to seperate my application datacontext into a seperate Dat project that ONLY deals with the data access, so this project would reference EF dlls but not ASP Identity components.


It would be as simple as



public class AppContext: DbContext
{
public AppContext(): base("DefaultConntection"){}

public DbSet<Customer> Customers { get; set; }
}


Of course this means I can't put the IdentityContext into this Data project, because I don't want to pollute my Data dlls, at the same time I don't want TWO Data access points.


How can I combine these two without polluting my Data project with Identity references? Is there a way I can use composition, partial classes or similar?


Aucun commentaire:

Enregistrer un commentaire