The following code fails in a migration:
SchemaBuilder.AlterTable("MyTable", table => table
.AlterColumn("MyColumn", c => c.WithDefault("MyColumn")));
The table previously had a default value, but the migration was supposed to change it. I get the following exception:
System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'set'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Orchard.Data.Migration.Interpreters.DefaultDataMigrationInterpreter.RunPendingStatements() in c:\Axess\Bridge\orchard\src\Orchard\Data\Migration\Interpreters\DefaultDataMigrationInterpreter.cs:line 336
at Orchard.Data.Migration.Interpreters.DefaultDataMigrationInterpreter.Visit(AlterTableCommand command) in c:\Axess\Bridge\orchard\src\Orchard\Data\Migration\Interpreters\DefaultDataMigrationInterpreter.cs:line 141
at Orchard.Data.Migration.Interpreters.AbstractDataMigrationInterpreter.Visit(ISchemaBuilderCommand command) in c:\Axess\Bridge\orchard\src\Orchard\Data\Migration\Interpreters\AbstractDataMigrationInterpreter.cs:line 17
at Orchard.Data.Migration.Schema.SchemaBuilder.Run(ISchemaBuilderCommand command) in c:\Axess\Bridge\orchard\src\Orchard\Data\Migration\Schema\SchemaBuilder.cs:line 58
at Orchard.Data.Migration.Schema.SchemaBuilder.AlterTable(String name, Action`1 table) in c:\Axess\Bridge\orchard\src\Orchard\Data\Migration\Schema\SchemaBuilder.cs:line 38
at Axbit.Search.Migrations.UpdateFrom5()
MpDzik created: https://orchard.codeplex.com/workitem/20354
The following code fails in a migration: SchemaBuilder.AlterTable("MyTable", table => table .AlterColumn("MyColumn", c => c.WithDefault("MyColumn")));
The table previously had a default value, but the migration was supposed to change it. I get the following exception: System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'set'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action
1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource
1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Orchard.Data.Migration.Interpreters.DefaultDataMigrationInterpreter.RunPendingStatements() in c:\Axess\Bridge\orchard\src\Orchard\Data\Migration\Interpreters\DefaultDataMigrationInterpreter.cs:line 336 at Orchard.Data.Migration.Interpreters.DefaultDataMigrationInterpreter.Visit(AlterTableCommand command) in c:\Axess\Bridge\orchard\src\Orchard\Data\Migration\Interpreters\DefaultDataMigrationInterpreter.cs:line 141 at Orchard.Data.Migration.Interpreters.AbstractDataMigrationInterpreter.Visit(ISchemaBuilderCommand command) in c:\Axess\Bridge\orchard\src\Orchard\Data\Migration\Interpreters\AbstractDataMigrationInterpreter.cs:line 17 at Orchard.Data.Migration.Schema.SchemaBuilder.Run(ISchemaBuilderCommand command) in c:\Axess\Bridge\orchard\src\Orchard\Data\Migration\Schema\SchemaBuilder.cs:line 58 at Orchard.Data.Migration.Schema.SchemaBuilder.AlterTable(String name, Action`1 table) in c:\Axess\Bridge\orchard\src\Orchard\Data\Migration\Schema\SchemaBuilder.cs:line 38 at Axbit.Search.Migrations.UpdateFrom5()