没有应用迁移。数据库已经是最新的。完毕
No migrations were applied. The database is already up to date. Done
我有一套模型:
我已经 运行 添加迁移命令
dotnet ef migrations add <migration name>
现在我设置了以下迁移:
当我启动 dotnet ef database update
时,我看到我的 tables 是 SQL 客户端并且一切正常。
当我连接到另一个数据库时出现问题。我想将迁移应用到新数据库。但是当我 运行 dotnet ef database update
我看到 No migrations were applied. The database is already up to date. Done.
消息。该命令只创建了我 __EFMigrationsHistory
table 并且它是空的。我如何在新数据库上使用我的迁移?
这是我的 ApplicationContext
public class ApplicationContext : DbContext
{
private readonly string _connectionString;
public ApplicationContext(IConfiguration configuration)
{
_connectionString = configuration.GetConnectionString("Recipes");
}
public DbSet<User> Users { get; set; }
public DbSet<Recipe> Recipes { get; set; }
public DbSet<RecipeStep> RecipeSteps { get; set; }
public DbSet<Ingredient> Ingridients { get; set; }
public DbSet<Category> Categories { get; set; }
public DbSet<Advertising> Advertisings { get; set; }
public DbSet<FileModel> Files { get; set; }
public DbSet<RecipeLike> RecipeLikes { get; set; }
public DbSet<RecipeDislike> RecipeDislikes { get; set; }
public DbSet<Bookmark> Bookmarks { get; set; }
public DbSet<Purchase> Purchases { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql(_connectionString);
}
}
和appsettings.json
{
"ConnectionStrings": {
"Recipes" : "connection string is here"
},
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
好的,我已经解决了我的问题。我丢失了 .Designer.cs
个文件。
丢了也会有同样的问题
我有一套模型:
我已经 运行 添加迁移命令
dotnet ef migrations add <migration name>
现在我设置了以下迁移:
当我启动 dotnet ef database update
时,我看到我的 tables 是 SQL 客户端并且一切正常。
当我连接到另一个数据库时出现问题。我想将迁移应用到新数据库。但是当我 运行 dotnet ef database update
我看到 No migrations were applied. The database is already up to date. Done.
消息。该命令只创建了我 __EFMigrationsHistory
table 并且它是空的。我如何在新数据库上使用我的迁移?
这是我的 ApplicationContext
public class ApplicationContext : DbContext
{
private readonly string _connectionString;
public ApplicationContext(IConfiguration configuration)
{
_connectionString = configuration.GetConnectionString("Recipes");
}
public DbSet<User> Users { get; set; }
public DbSet<Recipe> Recipes { get; set; }
public DbSet<RecipeStep> RecipeSteps { get; set; }
public DbSet<Ingredient> Ingridients { get; set; }
public DbSet<Category> Categories { get; set; }
public DbSet<Advertising> Advertisings { get; set; }
public DbSet<FileModel> Files { get; set; }
public DbSet<RecipeLike> RecipeLikes { get; set; }
public DbSet<RecipeDislike> RecipeDislikes { get; set; }
public DbSet<Bookmark> Bookmarks { get; set; }
public DbSet<Purchase> Purchases { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql(_connectionString);
}
}
和appsettings.json
{
"ConnectionStrings": {
"Recipes" : "connection string is here"
},
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
好的,我已经解决了我的问题。我丢失了 .Designer.cs
个文件。
丢了也会有同样的问题