解決策が見つからない奇妙な問題があります。EFコアでの移行は使用できません: "42P07:リレーション" AspNetRoles "は既に存在します。
スタックは、NETコア2、EF、PostgreSQLです。 .NET Core IdentityをUser : IdentityUser
で使用して、追加フィールドでベースユーザーモデルを拡張します。私は最初の移行を作成した後
、データベース全体を削除し、dotnet ef database update
にしようと、私は常にエラーを取得:これでもエラーで42P07: relation "AspNetRoles" already exists
を、データベースをとテーブルが作成されますが、それが適用され保存されませんので、それは無用の移行を作ります移行の結果、次の変更でDBを更新できません...
fail: Microsoft.EntityFrameworkCore.Database.Command[200102] Failed executing DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] CREATE TABLE "AspNetRoles" ( "Id" text NOT NULL, "ConcurrencyStamp" text NULL, "Name" varchar(256) NULL, "NormalizedName" varchar(256) NULL, CONSTRAINT "PK_AspNetRoles" PRIMARY KEY ("Id") ); Npgsql.PostgresException (0x80004005): 42P07: relation "AspNetRoles" already exists at Npgsql.NpgsqlConnector.d__148.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult() at System.Runtime.CompilerServices.ValueTaskAwaiter
1.GetResult()
at Npgsql.NpgsqlConnector.d__147.MoveNext()
移行の作成後にいくつかのものを変更しましたか?そのアクションは同様のエラーを発生させる可能性があります。 –
いいえ。私は何度も移行を削除し、それらを再度作成しようとしました。 –