如何跳过ef core中的某些迁移?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何跳过ef core中的某些迁移?相关的知识,希望对你有一定的参考价值。
我在ef上下文中进行了som更改,并添加了新的偏头痛
dotnet ef migrations add changed98112601
然后我运行以下命令
dotnet ef database update
我的输出如下,似乎要应用初始迁移。如何防止这种情况?
开始构建...构建成功。正在应用迁移'20191225133128_Initial'。执行DbCommand失败(159ms)[Parameters = [],CommandType ='Text',CommandTimeout = '30']创建表[诗]([Id] int NOT NULL IDENTITY,[Number] int NOT NULL,[含义] nvarchar(max)NULL,约束[PK_Poems]主键([Id]));Microsoft.Data.SqlClient.SqlException(0x80131904):数据库中已经有一个名为“ Poems”的对象。在E. agent1_work 34 s src Microsoft.Data.SqlClient netcore src Microsoft Data 中的Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException异常,布尔值BreakConnection,Action
1 wrapCloseInAction) in E:agent1\_work34ssrcMicrosoft.Data.SqlClient etcoresrcMicrosoftDataSqlClientSqlConnection.cs:line 1591 at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action
1 wrapCloseInAction) SqlClient SqlInternalConnection.cs:第618行在E. agent1_work 34 s src Microsoft.Data.SqlClient netcore src Microsoft Data SqlClient TdsParser中的Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj,Boolean callerHasConnectionLock,Boolean asyncClose)中。 cs:1169行在Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj,Boolean&dataReady)在E: agent1_work 34 s src Microsoft.Data.SqlClient netcore Microsoft Data SqlClient TdsParser.cs:第1719行在Microsoft.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName,Boolean isAsync,Int32 timeout,Boolean asyncWrite)在E: agent1_work 34 s src Microsoft.Data.SqlClient netcore src Microsoft Data SqlClient中 SqlCommand.cs:第2857行在Microsoft.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String methodName) in E:agent1\_work34ssrcMicrosoft.Data.SqlClient etcoresrcMicrosoftDataSqlClientSqlCommand.cs:line 1395 at Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery() in E:agent1\_work34ssrcMicrosoft.Data.SqlClient etcoresrcMicrosoftDataSqlClientSqlCommand.cs:line 974 at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary
2 parameterValues)在Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands,IRelationalConnection连接)在Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)在Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration,String contextType)在Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration,String contextType)在Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase。<> c__DisplayClass0_0。<.ctor>b__0()在Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action操作)ClientConnectionId:b1027e70-d231-407a-87a0-5b53d06d2782错误号:2714,状态:6,类别:16数据库中已经有一个名为“ Poems”的对象。
以上是关于如何跳过ef core中的某些迁移?的主要内容,如果未能解决你的问题,请参考以下文章
如何在 EF / EF Core 中的第二个表上实现具有某些条件的左连接?