I created a new WebSite in VS2012 - NOT a project - added the connection string, created tables, and then using ASPNET CONFIGURATION created a couple of roles and an user, which in turn automatically created the appropriated tables in my database: Users, UsersInRoles, Roles, Memberships and ROLES. Pretty much working as expected. With 4.5 (SimpleMembershipProvider) it doesn't create all the stored procedures and extra code is used to with the old MemberShipProvider.
I wanted to add some fields in the Profile provider, like I use to MembershipProvider:
<properties> <add name="myWhatEver" type="System.Int32" allowAnonymous="false"/> </properties>
But when I try to call in code behind, it said "Profile" doesn't exists. So I search on the web and read that with VS2012, if you create a website, instead of a project, it doesn't come with profile by default so you have to create a custom one.
Following that I added the following code in AppCode cs:
namespace myNameSpace {
public class UserProfile : ProfileBase { public static UserProfile GetUserProfile(string username) { return Create(username) as UserProfile; } public static UserProfile GetUserProfile() { return Create(Membership.GetUser().UserName) as UserProfile; } [SettingsAllowAnonymous(false)] public string myWhatEver1 { get { return base["myWhatEver1"] as string; } set { base["myWhatEver1"] = value; } } }
In WebConfig:
<profile defaultProvider="MYProfileProvider" inherits="myNameSpace.UserProfile">
<providers>
<clear />
<add name="MYProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="MYDBConn"/>
</providers>
</profile>
<membership defaultProvider="MYMembershipProvider">
<providers>
<clear />
<add name="MYMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="MYDBConn" applicationName="/"/>
</providers>
</membership>
<roleManager defaultProvider="MYRoleProvider">
<providers>
<clear />
<add name="MYRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="MYDBConn" applicationName="/"/>
</providers>
</roleManager>
I go to page behind and it recognizes my custom profile! I'm all exited until I run the page and get this:
Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.
Now what? Pretty sure SimpleMembershiProvider doesn't use stored procedures like MembershipProvider use to, and I really don't want to install MembershipProvider in the database. There must be something I can add to my code so it works as is.
Any suggestions??
Thanks.