Migration Problem ----------------- Key: DNET-801 URL: http://tracker.firebirdsql.org/browse/DNET-801 Project: .NET Data provider Issue Type: Bug Components: ADO.NET Provider Affects Versions: 5.9.1.0 Environment: Firebird 2.5 Reporter: Andreas Patock Assignee: Jiri Cincura
Hi Jiri, you wanted to post me this to the issue tracker - here it is. I have a problem add a new column via migration to a codefirst database. This is the code for the migration: public partial class StreamingModuleAddAddress2 : DbMigration { public override void Up() { AddColumn("dbo.StreamingModule", "Address1", c => c.String(nullable: false, maxLength: 23)); AddColumn("dbo.StreamingModule", "Address2", c => c.String(nullable: false, maxLength: 23)); AddColumn("dbo.StreamingModule", "Port1", c => c.Int(nullable: false)); AddColumn("dbo.StreamingModule", "Port2", c => c.Int(nullable: false)); DropColumn("dbo.StreamingModule", "Address"); DropColumn("dbo.StreamingModule", "Port"); } public override void Down() { AddColumn("dbo.StreamingModule", "Port", c => c.Int(nullable: false)); AddColumn("dbo.StreamingModule", "Address", c => c.String(nullable: false, maxLength: 23)); DropColumn("dbo.StreamingModule", "Port2"); DropColumn("dbo.StreamingModule", "Port1"); DropColumn("dbo.StreamingModule", "Address2"); DropColumn("dbo.StreamingModule", "Address1"); } } But when running entityframework creates the following sql: ALTER TABLE "StreamingModule" ADD "Address1" VARCHAR(23) DEFAULT CAST(_UTF8'' AS VARCHAR(0)) NOT NULL I think firebird doesn't allow the CAST in a DEFAULT statement! And this causes the following exception: FirebirdSql.Data.FirebirdClient.FbException was unhandled ErrorCode=335544569 HResult=-2147467259 Message=Dynamic SQL Error SQL error code = -104 Token unknown - line 1, column 66 CAST SQLSTATE=42000 Source=FirebirdSql.Data.FirebirdClient StackTrace: bei FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteNonQuery() bei System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<NonQuery>b__0(DbCommand t, DbCommandInterceptionContext`1 c) bei System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) bei System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext) bei System.Data.Entity.Internal.InterceptableDbCommand.ExecuteNonQuery() bei System.Data.Entity.Migrations.DbMigrator.ExecuteSql(MigrationStatement migrationStatement, DbConnection connection, DbTransaction transaction, DbInterceptionContext interceptionContext) bei System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection, DbTransaction transaction, DbInterceptionContext interceptionContext) bei System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsWithinTransaction(IEnumerable`1 migrationStatements, DbTransaction transaction, DbInterceptionContext interceptionContext) bei System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsWithinNewTransaction(IEnumerable`1 migrationStatements, DbConnection connection, DbInterceptionContext interceptionContext) bei System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection, DbInterceptionContext interceptionContext) bei System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection) bei System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClass30.<ExecuteStatements>b__2e() bei System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute(Action operation) bei System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements, DbTransaction existingTransaction) bei System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements) bei System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, VersionedModel targetModel, IEnumerable`1 operations, IEnumerable`1 systemOperations, Boolean downgrading, Boolean auto) bei System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration) bei System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId) bei System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration) bei System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClassc.<Update>b__b() bei System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) bei System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) bei System.Data.Entity.MigrateDatabaseToLatestVersion`2.InitializeDatabase(TContext context) bei System.Data.Entity.Internal.InternalContext.<>c__DisplayClassf`1.<CreateInitializationAction>b__e() bei System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) bei System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() bei System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c) bei System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) bei System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) bei System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() bei System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) bei System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() bei System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator() bei System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() bei System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) bei System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) bei ConsoleTester.Program.Main(String[] args) in C:\WorkDir_Trunk\Win\Bfe\KscSilknet\Database\ConsoleTester\Program.cs:Zeile 22. bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() bei System.Threading.ThreadHelper.ThreadStart_Context(Object state) bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Threading.ThreadHelper.ThreadStart() InnerException: ErrorCode=335544569 HResult=-2146233088 IsWarning=false Message=Dynamic SQL Error SQL error code = -104 Token unknown - line 1, column 66 CAST SQLSTATE=42000 Source=FirebirdSql.Data.FirebirdClient StackTrace: bei FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.ProcessResponse(IResponse response) bei FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.ReadResponse() bei FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.ReadGenericResponse() bei FirebirdSql.Data.Client.Managed.Version11.GdsStatement.Prepare(String commandText) bei FirebirdSql.Data.FirebirdClient.FbCommand.Prepare(Boolean returnsSet) bei FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior behavior, Boolean returnsSet) bei FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteNonQuery() InnerException: Do you have any Idea how to fix that? Kind regards, Andreas -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://tracker.firebirdsql.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Firebird-net-provider mailing list Firebird-net-provider@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/firebird-net-provider