Using Code First Entity Framework with .NET MVC 4 I have created a new Web Application and populated the database with object as shown below.
public class Gratif
Remove the AttachDbFileName from the DefaultConnectionString in web.config
<add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-GratifyGaming-20120917185558;Integrated Security=True" providerName="System.Data.SqlClient" />
Call the WebSecurity.InitialiseDatabase method in Global.asax.cs
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
Database.SetInitializer<GratifyGamingContext>(new DatabaseInitializer());
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
AuthConfig.RegisterAuth();
WebSecurity.InitializeDatabaseConnection(
connectionStringName: "DefaultConnection",
userTableName: "UserProfile",
userIdColumn: "UserID",
userNameColumn: "UserName",
autoCreateTables: true);
}
}
Comment out [InitializeSimpleMembership] in AccountController.cs
[Authorize]
//[InitializeSimpleMembership]
public class AccountController : Controller