/// <summary>
        ///     Adds a new SQL generator to be used for a given database provider.
        /// </summary>
        /// <param name="providerInvariantName"> Name of the database provider to set the SQL generator for. </param>
        /// <param name="migrationSqlGenerator"> The SQL generator to be used. </param>
        public void SetSqlGenerator(string providerInvariantName, MigrationSqlGenerator migrationSqlGenerator)
        {
            Check.NotEmpty(providerInvariantName, "providerInvariantName");
            Check.NotNull(migrationSqlGenerator, "migrationSqlGenerator");

            _sqlGenerators[providerInvariantName] = migrationSqlGenerator;
        }
Пример #2
0
 /// <summary>
 /// Adds a new SQL generator to be used for a given database provider.
 /// </summary>
 /// <param name="providerInvariantName"> Name of the database provider to set the SQL generator for. </param>
 /// <param name="migrationSqlGenerator"> The SQL generator to be used. </param>
 public void SetSqlGenerator(
     string providerInvariantName,
     MigrationSqlGenerator migrationSqlGenerator)
 {
     Check.NotEmpty(providerInvariantName, nameof(providerInvariantName));
     Check.NotNull <MigrationSqlGenerator>(migrationSqlGenerator, nameof(migrationSqlGenerator));
     this._sqlGenerators[providerInvariantName] = migrationSqlGenerator;
 }
Пример #3
0
        public static void RunMigration(this DbContext context, DbMigration migration)
        {
            var prop = migration.GetType().GetProperty("Operations", BindingFlags.NonPublic | BindingFlags.Instance);

            if (prop != null)
            {
                IEnumerable <MigrationOperation> operations = prop.GetValue(migration) as IEnumerable <MigrationOperation>;
                MigrationSqlGenerator            generator  = (new DbMigrationsConfiguration()).GetSqlGenerator("JetEntityFrameworkProvider");
                var statements = generator.Generate(operations, "Jet");
                foreach (MigrationStatement item in statements)
                {
                    context.Database.ExecuteSqlCommand(item.Sql);
                }
            }
        }
Пример #4
0
 internal static IEnumerable <MigrationStatement> GenerateMigrationStatements(
     TransactionContext context)
 {
     if (DbConfiguration.DependencyResolver.GetService <Func <MigrationSqlGenerator> >((object)context.InternalContext.ProviderName) != null)
     {
         MigrationSqlGenerator sqlGenerator         = context.InternalContext.MigrationsConfiguration.GetSqlGenerator(context.InternalContext.ProviderName);
         DbConnection          connection           = context.Database.Connection;
         CreateTableOperation  createTableOperation = (CreateTableOperation) new EdmModelDiffer().Diff(new DbModelBuilder().Build(connection).GetModel(), context.GetModel(), (Lazy <ModificationCommandTreeGenerator>)null, (MigrationSqlGenerator)null, (string)null, (string)null).Single <MigrationOperation>();
         string providerManifestToken = context.InternalContext.ModelProviderInfo != null ? context.InternalContext.ModelProviderInfo.ProviderManifestToken : DbConfiguration.DependencyResolver.GetService <IManifestTokenResolver>().ResolveManifestToken(connection);
         return(sqlGenerator.Generate((IEnumerable <MigrationOperation>) new CreateTableOperation[1]
         {
             createTableOperation
         }, providerManifestToken));
     }
     return((IEnumerable <MigrationStatement>) new MigrationStatement[1]
     {
         new MigrationStatement()
         {
             Sql = ((IObjectContextAdapter)context).ObjectContext.CreateDatabaseScript(),
             SuppressTransaction = true
         }
     });
 }
 public CustomOracleSqlCodeGen(MigrationSqlGenerator innerSqlGenerator)
 {
     _innerSqlGenerator = innerSqlGenerator;
 }
Пример #6
0
 public WrappingSqlGenerator(MigrationSqlGenerator baseGenerator)
 {
     _baseGenerator = baseGenerator;
 }
 /// <summary />
 /// <param name="migrationSqlGenerator">
 ///     SQL Generator que será decorado.
 /// </param>
 public MigrationSqlGeneratorWithDiscriminatorIndexSupport(MigrationSqlGenerator migrationSqlGenerator)
 {
     _migrationSqlGenerator = migrationSqlGenerator;
 }