Exception creating migration to Drop a table Pomelo 6.0.1
See original GitHub issueHi, im getting an Exception when trying to generate a migration to drop a table
.net 6 EF Core 6.0.1 Pomelo 6.0.1
I removed the Model entity (iUW.Models.ApplicantProduct) from the DbContext , and removed any references to it from the codebase.
when I run
add-migration dropTableApplicantProduct -context DatabaseUnitOfWork
I get this stack trace
add-migration dropTableApplicantProduct -context DatabaseUnitOfWork
Build started...
Build succeeded.
System.ArgumentException: An item with the same key has already been added. Key: [0, Property: iUW.Models.ApplicantProduct (Dictionary<string, object>).ProductId (no field, int) Indexer Required FK Index]
at System.Collections.Generic.TreeSet`1.AddIfNotPresent(T item)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.GetSortedProperties(IEntityType entityType, ITable table)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.GetSortedColumns(ITable table)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.Add(ITable target, DiffContext diffContext)+MoveNext()
at Pomelo.EntityFrameworkCore.MySql.Migrations.Internal.MySqlMigrationsModelDiffer.PostFilterOperations(IEnumerable`1 migrationOperations)+MoveNext()
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.DiffCollection[T](IEnumerable`1 sources, IEnumerable`1 targets, DiffContext diffContext, Func`4 diff, Func`3 add, Func`3 remove, Func`4[] predicates)+MoveNext()
at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
at Pomelo.EntityFrameworkCore.MySql.Migrations.Internal.MySqlMigrationsModelDiffer.PostFilterOperations(IEnumerable`1 migrationOperations)+MoveNext()
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.Sort(IEnumerable`1 operations, DiffContext diffContext)
at Pomelo.EntityFrameworkCore.MySql.Migrations.Internal.MySqlMigrationsModelDiffer.Sort(IEnumerable`1 operations, DiffContext diffContext)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.GetDifferences(IRelationalModel source, IRelationalModel target)
at Pomelo.EntityFrameworkCore.MySql.Migrations.Internal.MySqlMigrationsModelDiffer.GetDifferences(IRelationalModel source, IRelationalModel target)
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, String namespace)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType, String namespace)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
An item with the same key has already been added. Key: [0, Property: iUW.Models.ApplicantProduct (Dictionary<string, object>).ProductId (no field, int) Indexer Required FK Index]
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Exception creating migration to Drop a table #27418
Hi, im getting an Exception when trying to generate a migration to drop a table .net 6. EF Core 6.0.1. Pomelo 6.0.1.
Read more >.net 6.0 - Pomelo.EntityFrameworkCore.MySql problem ...
I fixed some of them but the last one, I couldn`t. System.InvalidOperationException: The property 'SqlClass.Disabled' is of type 'byte' which is ...
Read more >Breaking changes in EF Core 6.0
The following table illustrates the changes for Migrations. OnDelete(), ON DELETE. NoAction, NO ACTION. ClientNoAction, NO ACTION. Restrict ...
Read more >7.1 Entity Framework 6 Support
Idempotent migrations scripts allow you to generate an SQL script that can upgrade a database at any version up to the latest version....
Read more >PomeloFoundation
How can we give Pomelo the hint it needs to stop using ST_X and ST_Y ? Steps to reproduce. Table: CREATE TABLE `t_address`...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Great thanks for investigating @lauxjpn much appreciated.
@CliveBennett Looks like you found a bug in EF Core. This issue is also reproducible using the SQL Server provider:
Program.cs
Output
/cc @bricelam