Page 1 of 1

Object Null Ref when ef migrations down some cases with dotConnect MySQL

Posted: Mon 29 Aug 2016 05:39
by thoho
Environment:
driver dotConnect MySQL
.NET Core 1.0.0-RTM
EFCore 1.0.0
db server MySQL 5.6

Expected: Success
Actually:

Code: Select all

Finding DbContext classes...
Using context 'MyDbContext'.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Devart.Common.Entity.Migrations.b.a(c A_0, String A_1, String A_2, String A_3)
   at Devart.Common.Entity.Migrations.b.b(AlterColumnOperation A_0)
   at Devart.Common.Entity.Migrations.b.a(AlterColumnOperation A_0)
   at Devart.Common.Entity.Migrations.b.b(MigrationOperation A_0)
   at Devart.Common.Entity.Migrations.b.a(IEnumerable`1 A_0)
   at Devart.Common.Entity.Migrations.g.a(IEnumerable`1 A_0, au A_1)
   at Devart.Data.MySql.Entity.Migrations.MySqlEntityMigrationSqlGenerator.Generate(IReadOnlyList`1 migrationOperations, IModel model)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.GenerateDownSql(Migration migration, Migration previousMigration)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Microsoft.EntityFrameworkCore.Design.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
   at Microsoft.EntityFrameworkCore.Tools.Cli.DatabaseUpdateCommand.<>c__DisplayClass0_0.<Configure>b__0()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at Microsoft.EntityFrameworkCore.Tools.Cli.Program.Main(String[] args)
Object reference not set to an instance of an object.
Reproduce steps:

Code: Select all

ef migrations list
yyyymmddhhmmss_BeforeVarcharSizeChange
yyyymmddhhmmss_EmailLength50To150
yyyymmddhhmmss_AnyAfter
yyyymmddhhmmss_Latest
yyyymmddhhmmss_EmailLength50To150 has change property.HasMaxLength(150)

Code: Select all

ALTER TABLE my_table_name
MODIFY COLUMN email varchar(150) NOT NULL
INSERT INTO __EFMigrationsHistory (MigrationId, ProductVersion)
VALUES ('yyyymmddhhmmss_EmailLength50To150', '1.0.0-rtm-21431');
After update latest, when do rollback some migration, may get exception:
System.NullReferenceException: Object reference not set to an instance of an object.

Case 1:
From latest
ef database update AnyAfter => Sucess

Case 2:
From latest
ef database update EmailLength50To150 => Exception


Case 3:
From AnyAfter
ef database update EmailLength50To150 => Exception


Case 4:
From Latest
ef database update BeforeVarcharSizeChange => Sucess

Case 5:
From AnyAfter
ef database update BeforeVarcharSizeChange => Sucess

Workaround: Do not rollback the Varchar length changed directly

Re: Object Null Ref when ef migrations down some cases with dotConnect MySQL

Posted: Mon 29 Aug 2016 06:47
by Shalex
Please send us a small test project with the corresponding DDL/DML script for reproducing.

In case of >2MB attachment, we recommend either using some file exchange server (send us the corresponding link) or uploading a test project to our FTP server (the credentials will be provided by email request).