You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error creating full database script after migrations run #10
object reference not set to an instance of an object
If I specify any other source migration besides $IntialDatabase it works properly. Also, if I first revert all the way to zero then ask for script, it runs fine. So this is my current workaround:
I have confirmed this exact problem, using EF 6 and npgsql 2.2.7 for entity framework. By reverting to an empty database, this script will get generated. With migrations run, i also get the object null ref error. Here is more of the call stack:
System.NullReferenceException: Object reference not set to an instance of an object.
at Npgsql.NpgsqlMigrationSqlGenerator.Convert(IEnumerable1 operations) at Npgsql.NpgsqlMigrationSqlGenerator.Convert(IEnumerable1 operations)
at Npgsql.NpgsqlMigrationSqlGenerator.Generate(IEnumerable1 migrationOperations, String providerManifestToken) at System.Data.Entity.Migrations.DbMigrator.GenerateStatements(IList1 operations, String migrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.GenerateStatements(IList`1 operations, String migrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorScriptingDecorator.ScriptUpdate(String sourceMigration, String targetMigration)
at System.Data.Entity.Migrations.Design.ToolingFacade.ScriptUpdateRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.ScriptUpdate(String sourceMigration, String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Object reference not set to an instance of an object.
Made a fix for the error.
Do you think we can make the logic similar to the one used for the sqlserver, i.e. get latest migration id and then wrap every migration into if blocks using anonymous blocks or something else so that such a script can update any version of the database?
Any idea if the PR will be reviewed and merged anytime soon?
We use EntityFramework6.Npgsql and we need to generate the same script (With IF statements) that's generated for SQL Server. IT would be really appreciated.
Activity
roji commentedon May 12, 2016
From @peterz11 on September 25, 2015 21:29
I have confirmed this exact problem, using EF 6 and npgsql 2.2.7 for entity framework. By reverting to an empty database, this script will get generated. With migrations run, i also get the object null ref error. Here is more of the call stack:
System.NullReferenceException: Object reference not set to an instance of an object.
at Npgsql.NpgsqlMigrationSqlGenerator.Convert(IEnumerable
1 operations) at Npgsql.NpgsqlMigrationSqlGenerator.Convert(IEnumerable1 operations)at Npgsql.NpgsqlMigrationSqlGenerator.Generate(IEnumerable
1 migrationOperations, String providerManifestToken) at System.Data.Entity.Migrations.DbMigrator.GenerateStatements(IList1 operations, String migrationId)at System.Data.Entity.Migrations.Infrastructure.MigratorBase.GenerateStatements(IList`1 operations, String migrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorScriptingDecorator.ScriptUpdate(String sourceMigration, String targetMigration)
at System.Data.Entity.Migrations.Design.ToolingFacade.ScriptUpdateRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.ScriptUpdate(String sourceMigration, String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Object reference not set to an instance of an object.
xklonx commentedon Oct 9, 2020
Made a fix for the error.
Do you think we can make the logic similar to the one used for the sqlserver, i.e. get latest migration id and then wrap every migration into if blocks using anonymous blocks or something else so that such a script can update any version of the database?
ghorbey commentedon Feb 26, 2021
Any idea if the PR will be reviewed and merged anytime soon?
We use EntityFramework6.Npgsql and we need to generate the same script (With IF statements) that's generated for SQL Server. IT would be really appreciated.