Friday 15 March 2013

c# - ASP.NET MVC 5 Merging ApplicationUser with DbContext -



c# - ASP.NET MVC 5 Merging ApplicationUser with DbContext -

i'm trying integrate asp identity own dbcontext i'm having no luck it. i'm trying accomplish each deal posted, user assigned it.

dbcontext:

public class sharedealscontext : identitydbcontext<applicationuser> { public sharedealscontext() : base("name=sharedealscontext") { } // other dbsets public dbset<deals> deals { get; set; } }

deals model:

[foreignkey("user")] public virtual string userid { get; set; } public virtual applicationuser user { get; set; }

identity models:

public class applicationuser : identityuser { public async task<claimsidentity> generateuseridentityasync(usermanager<applicationuser> manager) { var useridentity = await manager.createidentityasync(this, defaultauthenticationtypes.applicationcookie); homecoming useridentity; } public virtual icollection<deals> deals { get; set; } } public class applicationdbcontext : identitydbcontext<applicationuser> { public applicationdbcontext() : base("defaultcontext", throwifv1schema: false) { } public static applicationdbcontext create() { homecoming new applicationdbcontext(); } }

i've tried replacing "defaultcontext" "sharedealscontext" within applicationdbcontext still not work. i'm wanting remove defaultcontext , utilize own sharedealscontext. ideas on missing out on? give thanks you

could replace defaultcontext connection string name web.config?

public applicationdbcontext() : base("connection_string_name", throwifv1schema: false)

for example,

web.config

c# asp.net asp.net-mvc entity-framework asp.net-mvc-5

No comments:

Post a Comment