using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Web;
using DataRepositories;
using WebMatrix.WebData;

namespace WebApplication
{
    public class SimpleMemberShipConfig
    {
        public static void Initialize()
        {
            if (!WebSecurity.Initialized)
            {
                WebSecurity.InitializeDatabaseConnection(Setttings.DatabaseConnectionString, "UserProfile", "Id",
                                                         "Login", autoCreateTables: true);
            }
        }

        public static void SimpleMembershipInitializer()
        {
            Database.SetInitializer<DataContext>(null);

            using (var context = new DataContext())
            {
                if (!context.Database.Exists())
                {
                    // Create the SimpleMembership database without Entity Framework migration schema
                    ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
                }
            }
        }
    }
}