Esempio n. 1
0
        public UsuariosRepositoryEF(Mvc4ApplicationSampleDbContext dbContext)
        {
            if (dbContext == null)
            {
                throw new ArgumentNullException("dbContext");
            }

            _dbContext = dbContext;
        }
Esempio n. 2
0
            public SimpleMembershipInitializer()
            {
                Database.SetInitializer <Mvc4ApplicationSampleDbContext>(null);

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

                    WebSecurity.InitializeDatabaseConnection(SettingsHelper.DefaultConnectionStringName, SettingsHelper.UserTableName, SettingsHelper.UserIdColumnName, SettingsHelper.UserNameColumnName, autoCreateTables: true);
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex);
                }
            }