Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove-Migration null-refs when generating report #9280

Closed
pranavkm opened this issue Jul 27, 2017 · 4 comments
Closed

Remove-Migration null-refs when generating report #9280

pranavkm opened this issue Jul 27, 2017 · 4 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@pranavkm
Copy link
Contributor

* Created a new 2.0.0 project
* Manually initialize EFCore.Tools (`&"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.entityframeworkcore.tools\2.0.0\tools\init.ps1"`)
* Invoke Add-Migration followed by removing it.

PM> Add-Migration test
Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using 'C:\Users\prkrishn\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
Microsoft.EntityFrameworkCore.Infrastructure[100403]
      Entity Framework Core 2.0.0-rtm-26452 initialized 'ApplicationDbContext' using provider 'Microsoft.EntityFrameworkCore.Sqlite' with options: None
To undo this action, use Remove-Migration.

PM> Remove-Migration 
Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using 'C:\Users\prkrishn\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
Microsoft.EntityFrameworkCore.Infrastructure[100403]
      Entity Framework Core 2.0.0-rtm-26452 initialized 'ApplicationDbContext' using provider 'Microsoft.EntityFrameworkCore.Sqlite' with options: None
Microsoft.EntityFrameworkCore.Database.Command[200101]
      Executed DbCommand (11ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      PRAGMA foreign_keys=ON;
Microsoft.EntityFrameworkCore.Database.Command[200101]
      Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      PRAGMA foreign_keys=ON;
Microsoft.EntityFrameworkCore.Database.Command[200101]
      Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
Microsoft.EntityFrameworkCore.Database.Command[200101]
      Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      PRAGMA foreign_keys=ON;
Microsoft.EntityFrameworkCore.Database.Command[200101]
      Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      SELECT "MigrationId", "ProductVersion"
      FROM "__EFMigrationsHistory"
      ORDER BY "MigrationId";
Removing migration '20170727182640_test'.
Reverting model snapshot.
Done.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.EntityFrameworkCore.Tools.Json.Escape(String text)
   at Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsRemoveCommand.ReportJsonResults(IDictionary result)
   at Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsRemoveCommand.Execute()
   at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
   at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Object reference not set to an instance of an object.
{
  "migrationFile": "C:\\Users\\prkrishn\\test\\Data\\Migrations\\20170727182640_test.cs",
  "metadataFile": "C:\\Users\\prkrishn\\test\\Data\\Migrations\\20170727182640_test.Designer.cs",

The migration gets removed and the ps script returns a 0-exit code, but the error makes it appear something's gone wrong.

@bricelam bricelam self-assigned this Jul 28, 2017
@bricelam
Copy link
Contributor

Strange that we don't handle null in JSON. I wonder why we're just now seeing this.

@divega divega added this to the 2.1.0 milestone Jul 28, 2017
@bricelam bricelam modified the milestones: 2.0.1, 2.1.0 Aug 11, 2017
@bricelam bricelam added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Aug 16, 2017
@bricelam bricelam reopened this Aug 18, 2017
@Eilon
Copy link
Member

Eilon commented Sep 15, 2017

This patch bug is approved for the 2.0.x patch. Please send a PR to the feature/2.0.1 branch and get it reviewed and merged. When we have the rel/2.0.1 branches ready please port the commit to that branch.

@Eilon
Copy link
Member

Eilon commented Oct 23, 2017

Hi, we have a public test feed that you can use to try out the ASP.NET/EF Core 2.0.3 patch!

To try out the pre-release patch, please refer to the following guide:

We are looking for feedback on this patch. We'd like to know if you have any issues with this patch by updating your apps and libraries to the latest packages and seeing if it fixes the issues you've had, or if it introduces any new issues. If you have any issues or questions, please reply on this issue to let us know as soon as possible.

Thanks,
Eilon

@hidayatarg
Copy link

hidayatarg commented Nov 7, 2018

Strange that we don't handle null in JSON. I wonder why we're just now seeing this.
I solve this by installing the following packages for 2.0 core

<PackageReference Include="Microsoft.EntityFramworkCore.SqlServer" Version="2.1.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.6" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.4">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

6 participants