【发布时间】:2018-03-31 01:17:21
【问题描述】:
我的 .net-core 2.0 应用程序的 PostgreSQL 数据库中有一个名为 checklist 的表,并且刚刚在 this doc 之后添加了 Identity Core。 之后,我跑了:
dotnet ef migrations add identity
dotnet ef database update
更新导致此错误:
Applying migration '20171018061542_InitialCreate'.
fail: Microsoft.EntityFrameworkCore.Database.Command[200102]
Failed executing DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
CREATE SEQUENCE "checklist_id_seq" START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE NO CYCLE;
Npgsql.PostgresException (0x80004005): 42P07: relation "checklist_id_seq" already exists
Identity Core 是否也会使用名为清单的表格,还是我在某处犯了错误?
编辑:Identity 未添加清单表和序列 checklist_id_seq。他们甚至在这是一个 .net-core 项目之前就已经存在(首先是 EF 数据库)。
我最近添加了迁移,并且 checklist_id_seq 的行存在于初始迁移中。
我所有的表都存在于 20171018061542_InitialCreate.Designer.cs(初始迁移)和 20171019031817_identity.Designer.cs(我所做的迁移,我想创建 Identity 使用的表)
所以我想问题是如何仅使用“身份”迁移中的新表来更新数据库?
Edit2:似乎这是 EF Core 迁移的问题。请参阅this SO question,以及这些问题:4237 和 2167
【问题讨论】:
标签: postgresql .net-core entity-framework-core entity-framework-migrations npgsql