Deploy ASP.NET MVC application with Membership to Azure

This article describes how to deploy an ASP.NET MVC application with the default Membership database to Azure,

Deploy a Secure ASP.NET MVC application with OAuth, Membership and SQL Database – .NET Web Development and Tools Blog – Site Home – MSDN Blogs.

The author uses Microsoft SQL Server Management Studio to generate an SQL script, and runs the script during Publish.

Another option is to create your own Membership table and Entity Framework Code First Migrations.

  1. First create your own Users table. It must have at least two fields: UserId and UserName,
    image
  2. Add the table to your DbContext,
    image
  3. Modify _AppStart.cshtml to run Migrations and then connect WebSecurity to the new Users table,
    image
  4. Run the application to create the table and test Membership.
  5. Finally, Publish the application to Azure using the option to Execute Code First Migrations,
    SNAGHTML8d6cb9

Note that if you want to seed the Users table, you will need to do it in _AppStart.cshtml,
image

Happy coding!

This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.