Prerequisites
Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.
- What is your product version?
- V11.3.0
- What is your product type (Angular or MVC)?
- What is product framework type (.net framework or .net core)? Net Core 6
If issue related with ABP Framework
- What is ABP Framework version? > 7.3.0
If issue is about UI
- Which theme are you using? Default
- What are the theme settings? Default
Hello I am getting this error with Update-Database command. What should I do after this error?
Note: I removed mu current database and run the command on "V11.3.0"
Applying migration '20220620111335_Upgraded_To_Abp_7_3_0'.
Failed executing DbCommand (6ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
ALTER TABLE [AbpUserNotifications] ADD [TargetNotifiers] nvarchar(max) NULL;
Microsoft.Data.SqlClient.SqlException (0x80131904): Column names in each table must be unique. Column name 'TargetNotifiers' in table 'AbpUserNotifications' is specified more than once.
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action
1 wrapCloseInAction)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean isAsync, Int32 timeout, Boolean asyncWrite)
at Microsoft.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String methodName) at Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary
2 parameterValues)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
ClientConnectionId:58433607-e156-4f23-bc81-7f7f5416db4d
Error Number:2705,State:4,Class:16
Column names in each table must be unique. Column name 'TargetNotifiers' in table 'AbpUserNotifications' is specified more than once.
PM>
2 Answer(s)
-
0
Hi @LAD666
I could not reproduce it in clean project. Can you please check that https://stackoverflow.com/questions/32845336/column-names-in-each-table-must-be-unique-column-name-striperecipientid-in-ta. If it does not solves your problem. Can you please try removing one of these https://github.com/aspnetzero/aspnet-zero-core/blob/f790a94013d76819e7580ef907149107f7f7327d/aspnet-core/src/MyCompanyName.AbpZeroTemplate.EntityFrameworkCore/Migrations/20221014130904_Upgraded_To_Abp_7_4.cs#L15-L33 and these https://github.com/aspnetzero/aspnet-zero-core/blob/f790a94013d76819e7580ef907149107f7f7327d/aspnet-core/src/MyCompanyName.AbpZeroTemplate.EntityFrameworkCore/Migrations/20221014130904_Upgraded_To_Abp_7_4.cs#L49-L67
-
0
I encountered a problem with the "TargetNotifiers" column with update-database from version 11.2.1 to 11.4.0 on a migration 20220607073405_Add_Mass_Notifications. As that migration only attempted to add that column, I was able to proceed by removing the .cs file for the migration (in <project>.EntityFrameworkCore), rebuilding, and running update-database again.
Seems like this could be a problem for future releases if that migration is left in the release. Should it be removed from the aspnet-zero-core project?