Beispiel #1
0
 /// <summary>
 /// Gets content of a migration sql file.
 /// We assume that the migration was scaffolded with
 /// <see cref="IMigrationMetadata"/> interface and use its
 /// Id property to target file in
 /// DatabaseProject\Migrations\{Id}\<paramref name="sqlFileName"/>.sql
 /// </summary>
 /// <param name="sqlFileName"></param>
 /// <param name="folder"></param>
 /// <returns></returns>
 private string GetMigrationScript(string sqlFileName, string folder = "")
 {
     return(DbMigrationPath.CombineAndReadAll(
                this.dbMigrationPath.MigrationsFolderPath,
                ((IMigrationMetadata)this).Id,
                folder, // I can do this because path.Combine("Folder1", "", "File"); returns Folder1/File
                $"{sqlFileName}.sql"));
 }
Beispiel #2
0
        private void DatabaseSqlFile(string sqlFileName, string folder = "", bool suppressTransaction = false, string assemblyPath = "")
        {
            var factory = new EntityFrameworkViewMigrationsSectionFactory();
            var configurationSection = factory.GetSectionFromCurrentAssembly(assemblyPath);

            this.dbMigrationPath   = new DbMigrationPath(configurationSection.DatabaseProject);
            this.initialDataParser = new InitialDataParser(this.dbMigrationPath);

            this.Sql(SqlDataParser.WrapSqlFileWithExec(this.GetMigrationScript(sqlFileName, folder)), suppressTransaction);
        }
Beispiel #3
0
        protected void Seed()
        {
            // This is not the best solution... because i can not use the SeedDbMigration. It has wrong calling assemlby :( F**K THIS SHIT
            var assemblyPath         = Assembly.GetCallingAssembly().EscapedCodeBase; // Can not call inside the Factory/Initialize !!!
            var factory              = new EntityFrameworkViewMigrationsSectionFactory();
            var configurationSection = factory.GetSectionFromCurrentAssembly(assemblyPath);

            this.dbMigrationPath   = new DbMigrationPath(configurationSection.DatabaseProject);
            this.initialDataParser = new InitialDataParser(this.dbMigrationPath);

            foreach (string sql in this.initialDataParser.Parse())
            {
                this.Sql(SqlDataParser.WrapSqlFileWithExec(sql));
            }
        }