You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PM> Update-Database -Context XXX_DbContext -Project XXX.Migrations -StartupProject XXX
Build started...
Build succeeded.
fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
Failed executing DbCommand (18ms) [Parameters=[], CommandType='Text', CommandTimeout='600']
ALTER TABLE [L].[MyTable] ADD CONSTRAINT [CK_MyTable_MyColumn_Enum_Constraint] CHECK ([MyColumn] IN(0, 1, 2));
Failed executing DbCommand (18ms) [Parameters=[], CommandType='Text', CommandTimeout='600']
ALTER TABLE [L].[MyTable] ADD CONSTRAINT [CK_MyTable_MyColumn_Enum_Constraint] CHECK ([MyColumn] IN(0, 1, 2));
Microsoft.Data.SqlClient.SqlException (0x80131904): There is already an object named 'CK_MyTable_MyColumn_Enum_Constraint' in the database.
Could not create constraint or index. See previous errors.
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 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(TaskCompletionSource`1 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:d4f9b048-76a6-4274-8abb-97bca4430e91
Error Number:2714,State:5,Class:16
There is already an object named 'CK_MyTable_MyColumn_Enum_Constraint' in the database.
Could not create constraint or index. See previous errors.
PM>
Using Script-Migrations I can observe, that there are three occurrences of: ALTER TABLE [MySchema].[MyTable] ADD CONSTRAINT [CK_MyTable_MyColumn_Enum_Constraint] CHECK ([MyColumn] IN(0, 1, 2));
I have tried to check approximately 10 different ALTER TABLE [MySchema].[MyTable] ADD CONSTRAINT [CK_..._..._Enum_Constraint] CHECK ([.] IN(...)); statements.They were all repeated 3 times each.
Is there an error in EF Core 5.0 Preview 4 that these ...Enum_Constraint constraints are simply repeated three times and I just need to wait for Preview 5.
The text was updated successfully, but these errors were encountered:
@roji In order to continue, I decided to remove the migrations added by former versions, simply by removing the files and folders in the Migrations folder. Afterwards I got stuck by #21010 (comment).
Therefore I don't know, if there are still generated multiple definitions. If the problems persist after I overcome the too long name of constraint issue, I will obviously aim to post such a small sample as you request.
Duplicate of #18958. Note however that automatic generation of these constraints has been removed from 5.0 and moved to an external package--see #20897.
Update-Database fails with the information:
Using Script-Migrations I can observe, that there are three occurrences of:
ALTER TABLE [MySchema].[MyTable] ADD CONSTRAINT [CK_MyTable_MyColumn_Enum_Constraint] CHECK ([MyColumn] IN(0, 1, 2));
I have tried to check approximately 10 different
ALTER TABLE [MySchema].[MyTable] ADD CONSTRAINT [CK_..._..._Enum_Constraint] CHECK ([.] IN(...));
statements.They were all repeated 3 times each.Is there an error in EF Core 5.0 Preview 4 that these
...Enum_Constraint
constraints are simply repeated three times and I just need to wait for Preview 5.The text was updated successfully, but these errors were encountered: