Ejemplo n.º 1
0
        /// <summary>
        /// Connects the database.
        /// </summary>
        private void ConnectDB()
        {
            Logger.Debug("ConnectDB...");

            try
            {
                // Add this code line to fix following bug:
                // System.InvalidOperationException: The model backing the 'DBEntities'
                // context has changed since the database was created.
                // Consider using Code First Migrations to update the database
                // (http://go.microsoft.com/fwlink/?LinkId=238269).
                Database.SetInitializer <RFODbContext>(null);
                SimpleMembershipInitializer <RFODbContext> .Initialize();

                SimpleMembershipInitializer <RFODbContext> .CreateRoles(
                    new string[]
                {
                    AppConstants.AdminRole,
                    AppConstants.EmployeeRole,
                    AppConstants.UserRole,
                });
            }
            catch (Exception ex)
            {
                throw new DatabaseException(ex.ToString());
            }

            Logger.Debug("ConnectDB...DONE");
        }