0
rafalpiotrowski created
Hi, I try to add migration to EF and get null pointer exception
How can I debug the process?
PM> Add-Migration "Added_xxx" -Context xxxDbContext
Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework\Add-Migration' for Entity Framework 6.
System.NullReferenceException: Odwołanie do obiektu nie zostało ustawione na wystąpienie obiektu.
w Microsoft.EntityFrameworkCore.Update.Internal.SharedTableEntryMap`1.CreateSharedTableEntryMapFactory(IReadOnlyList`1 entityTypes, IStateManager stateManager, String tableName, String schema)
w Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.DiffData(TableMapping source, TableMapping target, DiffContext diffContext)
w Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.<Diff>d__35.MoveNext()
w Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.<DiffCollection>d__73`1.MoveNext()
w System.Linq.Enumerable.<ConcatIterator>d__59`1.MoveNext()
w System.Linq.Enumerable.<ConcatIterator>d__59`1.MoveNext()
w System.Linq.Enumerable.<ConcatIterator>d__59`1.MoveNext()
w System.Linq.Enumerable.<ConcatIterator>d__59`1.MoveNext()
w Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.Sort(IEnumerable`1 operations, DiffContext diffContext)
w Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.GetDifferences(IModel source, IModel target)
w Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.ScaffoldMigration(String migrationName, String rootNamespace, String subNamespace, String language)
w Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
w Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
w Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_1.<.ctor>b__0()
w Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
w Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Odwołanie do obiektu nie zostało ustawione na wystąpienie obiektu.
1 Answer(s)
-
0
removed all migrations and run
- Add-Migration InitialCreate
- changed first entry in
__EFMigrationsHistory
MigrationId = 20190130234948_InitialCreate and ProductVersion to the one from XXXDbContextModelSnaphot - removed all other entried in the
__EFMigrationsHistory
table except the first one that we changed
not Add-Migration works and can add new migrations