protected override void Generate(MigrationOperation migrationOperation)
        {
            var op = migrationOperation as CreateFullTextIndexOperation;
            if (op != null)
            {
                using (var writer = Writer())
                {
                    writer.WriteLine("IF(NOT EXISTS(SELECT * FROM SYS.fulltext_catalogs WHERE is_default = 1))");
                    writer.WriteLine("BEGIN");
                    writer.WriteLine("    CREATE FULLTEXT CATALOG DefaultFullTextCatalog AS DEFAULT");
                    writer.WriteLine("END");

                    writer.WriteLine();

                    writer.WriteLine("CREATE FULLTEXT INDEX ON {0} ({1})", Name(op.Table), string.Join(", ", op.Columns.Select(c => Quote(c))));
                    writer.WriteLine("KEY INDEX {0}", Quote(op.Index));
                    writer.WriteLine("WITH CHANGE_TRACKING AUTO");

                    Statement(writer.InnerWriter.ToString(), suppressTransaction: true);
                }
            }
            else
            {
                base.Generate(migrationOperation);
            }
        }
 protected override void Generate(System.Data.Entity.Migrations.Model.MigrationOperation migrationOperation)
 {
     if (migrationOperation is CreateViewOperation)
     {
         var operation = migrationOperation as CreateViewOperation;
         if (operation != null)
         {
             using (IndentedTextWriter writer = Writer())
             {
                 writer.WriteLine("CREATE VIEW {0} AS {1};",
                                  operation.ViewName,
                                  operation.ViewString);
                 Statement(writer);
             }
         }
     }
     else if (migrationOperation is DropViewOperation)
     {
         var operation = migrationOperation as DropViewOperation;
         if (operation != null)
         {
             using (IndentedTextWriter writer = Writer())
             {
                 writer.WriteLine("DROP VIEW {0};",
                                  operation.ViewName);
                 Statement(writer);
             }
         }
     }
     //base.Generate(migrationOperation);
 }
 protected override void Generate(MigrationOperation migrationOperation)
 {
     var commentOperation = migrationOperation as CommentOperation;
     if (commentOperation != null)
     {
         Statement(string.Format("-- {0}", commentOperation.Text));
     }
     else
     {
         base.Generate(migrationOperation);
     }
 }
        protected override void Generate(MigrationOperation migrationOperation)
        {
            var operation = migrationOperation as GrantPermissionOperation;
            if (operation != null)
            {
                using (var writer = Writer())
                {
                    writer.WriteLine(
                      "GRANT {0} ON {1} TO {2}",
                      operation.Permission.ToString().ToUpper(),
                      operation.Table,
                      operation.User);

                    Statement(writer);
                }
            }
            base.Generate(migrationOperation);
        }
Esempio n. 5
0
        public void FactMethodName()
        {
            var ops = new MigrationOperation[]
                          {
                              new AddColumnOperation("dbo.__MigrationHistory", 
                                  new ColumnModel(PrimitiveTypeKind.String)), 
                                  new DropPrimaryKeyOperation(), 
                                  new AddPrimaryKeyOperation()
                          };

            Assert.True(
                ops.Select(o => o.GetType()).SequenceEqual(
                    new[]
                        {
                            typeof(AddColumnOperation),
                            typeof(DropPrimaryKeyOperation),
                            typeof(AddPrimaryKeyOperation)
                        }));
        }
		protected override void Generate( MigrationOperation migrationOperation )
		{
			var createVperation = migrationOperation as CreateViewOperation;
			if( createVperation != null )
			{
				using( IndentedTextWriter writer = Writer() )
				{
					writer.WriteLine( "CREATE VIEW {0} AS {1} ; ", createVperation.ViewName, createVperation.ViewString );
					Statement( writer );
				}
			}

			var dropVperation = migrationOperation as DropViewOperation;
			if( dropVperation != null )
			{
				using( IndentedTextWriter writer = Writer() )
				{
					writer.WriteLine( "DROP VIEW {0}; ", dropVperation.ViewName );
					Statement( writer );
				}
			}
		}
 protected IEnumerable<MigrationStatement> Generate(MigrationOperation operation)
 {
     throw new NotSupportedException(string.Format("Unknown operation '{0}'.", operation.GetType().FullName));
 }
        /// <summary>
        /// Generates SQL for a <see cref="MigrationOperation" />.
        /// Allows derived providers to handle additional operation types.
        /// Generated SQL should be added using the Statement method.
        /// </summary>
        /// <param name="migrationOperation"> The operation to produce SQL for. </param>
        protected virtual void Generate(MigrationOperation migrationOperation)
        {
            Check.NotNull(migrationOperation, "migrationOperation");

            throw Error.SqlServerMigrationSqlGenerator_UnknownOperation(GetType().Name, migrationOperation.GetType().FullName);
        }
 protected override void Generate(MigrationOperation migrationOperation)
 {
     this.Generate((dynamic)migrationOperation);
     base.Generate(migrationOperation);
 }
        private static bool AnnotationsExist(MigrationOperation[] operations)
        {
            DebugCheck.NotNull(operations);

            return operations.OfType<IAnnotationTarget>().Any(o => o.HasAnnotations);
        }