gpt4 book ai didi

mysql - 初始添加迁移认为数据库已经是最新的

转载 作者:行者123 更新时间:2023-11-29 10:25:52 34 4
gpt4 key购买 nike

我正在尝试在我的项目中完全重置 EF Core 代码优先迁移。我有充分的理由这样做(如果需要可以解释),但我很难让它发挥作用。

我已经删除了以前的数据库并删除了项目中的旧迁移目录。

请参阅下面的日志。大约往下看四分之三,您会看到 EF 认为数据库已经是最新的。但是,您看到它一开始就创建了一个新的数据库吗?注意:我在日志末尾截断了很多内容,因为它只是堆栈跟踪错误,因为它找不到它认为应该已经存在的表。

有关如何重新创建新的初始迁移并更新数据库的任何指导吗?

PM> Add-Migration InitialCreate
Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using 'C:\Users\CollinB\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
Microsoft.EntityFrameworkCore.Infrastructure[10403]
Entity Framework Core 2.0.1-rtm-125 initialized 'FilterListsDbContext' using provider 'Pomelo.EntityFrameworkCore.MySql' with options: MaxPoolSize=128 MigrationsAssembly=FilterLists.Api
Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (4ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
CREATE DATABASE `filterlistsdata`;
Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (33ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
CREATE TABLE `__EFMigrationsHistory` (
`MigrationId` varchar(95) NOT NULL,
`ProductVersion` varchar(32) NOT NULL,
CONSTRAINT `PK___EFMigrationsHistory` PRIMARY KEY (`MigrationId`)
);
Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (18ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='filterlistsdata' AND TABLE_NAME='__EFMigrationsHistory';
Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (4ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT `MigrationId`, `ProductVersion`
FROM `__EFMigrationsHistory`
ORDER BY `MigrationId`;
Microsoft.EntityFrameworkCore.Migrations[20405]
**No migrations were applied. The database is already up to date.**
fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
Failed executing DbCommand (1ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT CASE
WHEN EXISTS (
SELECT 1
FROM `languages` AS `l`)
THEN TRUE ELSE FALSE
END
MySql.Data.MySqlClient.MySqlException (0x80004005): Table 'filterlistsdata.languages' doesn't exist ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Table 'filterlistsdata.languages' doesn't exist

最佳答案

我明白了。我没有意识到当我运行初始添加迁移时应用程序实际上运行。它正在运行我的一些 seed code这导致它失败。暂时注释掉允许我的初始创建运行。

关于mysql - 初始添加迁移认为数据库已经是最新的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48324630/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com