asp.net mvc 4 - Custom simple membership provider adding row -
i have custom simplemembershipprovider
, have defined tables simplemembershipprovider
requires, webpages_membership:
[table("webpages_membership")] public class membership { public membership() { roles = new list<role>(); oauthmemberships = new list<oauthmembership>(); } [key, databasegenerated(databasegeneratedoption.none)] public int userid { get; set; } public datetime? createdate { get; set; } [stringlength(128)] public string confirmationtoken { get; set; } public bool? isconfirmed { get; set; } public datetime? lastpasswordfailuredate { get; set; } public int passwordfailuressincelastsuccess { get; set; } [required, stringlength(128)] public string password { get; set; } public datetime? passwordchangeddate { get; set; } [required, stringlength(128)] public string passwordsalt { get; set; } [stringlength(128)] public string passwordverificationtoken { get; set; } public datetime? passwordverificationtokenexpirationdate { get; set; } public icollection<role> roles { get; set; } [foreignkey("userid")] public icollection<oauthmembership> oauthmemberships { get; set; } }
but how add record in table within seed()
method in configuration.cs file migrations creates when enabled?
assuming have custom membership provider correctly configured in web.config should able add record in seed method doing this.
var membership = (mymembershipnamespace.simplemembershipprovider)membership.provider; membership.createuserandaccount("test", "password");
Comments
Post a Comment