Create MVC4 Membership Database

I am familiar with aspnet_regsql.exe for creating a membership database (it creates 11 tables)

However, my MVC4 project VS2010 created a membership database with six tables (applications, memberships, profiles, roles, users and users of InRoles)

How to create a database using this (new?) Schema?

+7
source share
3 answers

aspnet_regsql.exe is part of the ASP.Net architecture, not MVC.

My bet is that MVC4 Developer Preview comes with some custom schema scripts in its project structure or that it has a preview version of the new ASP.Net 4.5 version of aspnet_regsql.exe .

If the latter is true, you can use this to create a database and bind it to your MVC3 applications (and earlier). The consequences here are related to the differences in the scheme, you will most likely have to write your own Providers.

Another option would be to create a database with your MVC4 template, delete the project, and encode DA level in your MVC3 project that uses the database. All you need to capture is a connection string. But then again, you will have to roll back your own providers, as the old ones will not know the new 6-table schema.

+2
source

All you have to do is:

modify your web.config to indicate the connection you would like

 <add name="DefaultConnection" connectionString="uid=****;pwd=*****;server=(local);database=****" providerName="System.Data.SqlClient" /> 

Check Filters \ InitializeSimpleMembershipAttribute.cs

Line 41 should read:

 WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true); 

Note that the autoCreateTables parameter is set to true and the name of the connection established in the web.config file is specified.

Now, when the user registers, he will search for the database that you have configured. If tables have not yet been created, they will be created.

+4
source

You need to add some arguments to install the functions: http://msdn.microsoft.com/en-us/library/ms229862(v=vs.80).aspx

You can run Aspnet_regsql.exe without command line arguments to launch a wizard that guides you through the installation.

What tables are missing and which tables were created?

+2
source

All Articles