Beispiel #1
0
        /// <summary>
        /// Initialize database with roles, users, categories from config directory
        /// </summary>
        public void SeedInitialize()
        {
            CheckDbConnectionAndExitIfFailed();

            using var db = new DataBaseConnection(providerName, connectionString);

            var dataContainer  = new InitialSeeder(new PathService(configuration)).Seed();
            var databaseSeeder = new DataBaseSeeder(db, dataContainer);

            databaseSeeder.SeedInitial();
        }
Beispiel #2
0
        /// <summary>
        /// Initialize database with roles, users, categories from config directory
        /// </summary>
        public void SeedInitialize()
        {
            using (var db = new DataBaseConnection(providerName, connectionString))
            {
                var dataContainer  = new InitialSeeder(configDirectoryPath).Seed();
                var databaseSeeder = new DataBaseSeeder(db, dataContainer);

                try
                {
                    databaseSeeder.SeedInitial();
                }
                catch (DbException e)
                {
                    throw new SunDataBaseException(
                              "Exception happened in data seed process. " +
                              "Check that last migrations were done('migrate' argument).", e);
                }
                catch (SocketException e)
                {
                    throw new SunDataBaseException("The connection could not be made. " +
                                                   "Check the database you are trying to connect exists.", e);
                }
            }
        }