entity framework - ASP.NET MVC domain Models and Identity Models in same context - UserLogin has no key -
i want application models in same dbcontext has identity model. inserted classes identitydbcontext this:
public partial class applicationdbcontext : identitydbcontext<applicationuser> { public applicationdbcontext() : base("humantask") { } public virtual dbset<wfinstance> wfinstance { get; set; } public virtual dbset<wfservice> wfservice { get; set; } public virtual dbset<wftask> wftask { get; set; } public virtual dbset<wfworkflow> wfworkflow { get; set; } protected override void onmodelcreating(dbmodelbuilder modelbuilder) { modelbuilder.entity<wftask>() .property(e => e.wftaskid) .isunicode(false); modelbuilder.entity<wfworkflow>() .property(e => e.name) .isunicode(false); } }
}
now, when try create new controller 1 of classes classes using scaffold
i message this:
i think i'm missing on onmodelcreating function, cant tell what. ?
from error looks missing key attributes identityuserlogin , identityuser role models. need specify key on model this:
public partial class identityuserlogin { [key] public string username { get; set; } }
or can specify fluent api
modelbuilder.entity<identityuserlogin>() .haskey(t => t.username);
Comments
Post a Comment