public override IEnumerable <MigrationStatement> Generate(
            IEnumerable <MigrationOperation> migrationOperations,
            string providerManifestToken)
        {
            // usa o `DiscriminatorIndexAnnotationProcessor` para substituir as anotações
            // do DiscriminatorIndex pelas operações de Create/Rename/Delete index.
            migrationOperations = DiscriminatorIndexAnnotationProcessor.Process(migrationOperations);

            // continua o processamento utilizando o SQL Generator decorado.
            return(_migrationSqlGenerator.Generate(migrationOperations, providerManifestToken));
        }
Beispiel #2
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);
                }
            }
        }
Beispiel #3
0
        public override IEnumerable <MigrationStatement> Generate(
            IEnumerable <MigrationOperation> migrationOperations,
            string providerManifestToken)
        {
            var items = new StringBuilder();

            foreach (var operation in migrationOperations)
            {
                items.Append(operation.GetType().Name).Append(' ');
            }

            WrappingAdoNetProvider <TAdoNetBase> .Instance.Log.Add(
                new LogItem("Generate", null, items.ToString()));

            return(_baseGenerator.Generate(migrationOperations, providerManifestToken));
        }
Beispiel #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 override IEnumerable<MigrationStatement> Generate(IEnumerable<MigrationOperation> migrationOperations, string providerManifestToken)
 {
     var ms = _innerSqlGenerator.Generate(AddCommentSqlStatements(migrationOperations), providerManifestToken);
     
     return ms;
 }