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

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
thoho
Posts: 6
Joined: Mon 11 Jul 2016 07:05

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

Post by thoho » Mon 29 Aug 2016 05:39

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

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

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

Post by Shalex » Mon 29 Aug 2016 06:47

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).

Post Reply