Dotnet ef migrations add ExtendApplicationUser -c ApplicationIdentityDbContext

Hi Guys, I'm working through Blazor extend application User and the migration fails with "Object reference not set to an instance of an object." any Idea's what is going on here.

Thanks

Rob

C:\Users\Rob31\Source\Repos\Hivoltech\server>dotnet ef migrations add ExtendApplicationUser -c ApplicationIdentityDbContext
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
Entity Framework Core 3.0.0 initialized 'ApplicationIdentityDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.EntityFrameworkCore.Metadata.Internal.EntityType.OnAnnotationSet(String name, IConventionAnnotation annotation, IConventionAnnotation oldAnnotation)
at Microsoft.EntityFrameworkCore.Metadata.Internal.ConventionAnnotatable.OnAnnotationSet(String name, Annotation annotation, Annotation oldAnnotation)
at Microsoft.EntityFrameworkCore.Infrastructure.Annotatable.RemoveAnnotation(String name)
at Microsoft.EntityFrameworkCore.Infrastructure.Annotatable.Microsoft.EntityFrameworkCore.Metadata.IMutableAnnotatable.RemoveAnnotation(String name)
at Microsoft.EntityFrameworkCore.Migrations.Internal.SnapshotModelProcessor.ProcessElement(IAnnotatable metadata, String version)
at Microsoft.EntityFrameworkCore.Migrations.Internal.SnapshotModelProcessor.ProcessElement(IEntityType entityType, String version)
at Microsoft.EntityFrameworkCore.Migrations.Internal.SnapshotModelProcessor.Process(IModel model)
at Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.ScaffoldMigration(String migrationName, String rootNamespace, String subNamespace, String language)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Object reference not set to an instance of an object.

Try the following:

  1. Add the server\Data\Migrations directory to Radzen's code generation ignore list.
  2. Open server\Data\Migrations\00000000000000_CreateIdentitySchema.Designer.cs with Visual Studio (or any other text editing program) and replace .HasAnnotation("ProductVersion", "1.0.0-rc3") with .HasAnnotation("ProductVersion", "3.0.0")
  3. Do the same for server\Data\Migrations\IdentityModelSnapshot.cs

Alternatively you can wait for us to release the fix next week. We plan a new update with a lot of changes related to the updated CRM sample tutorial for Blazor (which should also be a fact next week).

Thanks, I'm looking forward to the Blazor tutorial.

Was there a resolution to this issue? I am experiencing the same thing. I updated the file properties in the migrations folder as instructed but this hasnt helped.

Hi @Hakim4u,

Are you trying this in an application created with Radzen Blazor Studio? It should work out of the box.

Here is what I tried.

  1. Added a new property FullName to ApplicationUser.cs
  2. Executed dotnet ef migrations add ExtendApplicationUser -c ApplicationIdentityDbContext. It ran without issues and created two migration files.
    migrations