當我想在資料庫中添加欄位時,它會告訴我"SQLite Error 1: 'no such table: Players'.",但只要我查看我的資料庫,就會有一個玩家表。我怎么解決這個問題?
這是保存在資料庫中的檔案
游戲資料庫背景關系
namespace MereTuBois.Data
{
public class GameDbContext : DbContext
{
private readonly IDeviceService _deviceService;
public DbSet<Players> Players { get; set; }
public DbSet<Session> Sessions { get; set; }
public GameDbContext(IDeviceService deviceService)
{
_deviceService = deviceService;
//this.Database.EnsureCreated();
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
string dbPath = Path.Combine(_deviceService?.AppDataDirectory ?? ".", "mereTubois.db3");
optionsBuilder.UseSqlite($"Filename={dbPath}");
}
}
public class HistoryContextFacotry : IDesignTimeDbContextFactory<GameDbContext>
{
public GameDbContext CreateDbContext(string[] args)
{
return new GameDbContext(null);
}
}
}
遷移鏈接:https://github.com/Waterlok653/MIgration
uj5u.com熱心網友回復:
為了解決這個問題,我洗掉了以下評論:this.Database.EnsureCreated();
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/507000.html
上一篇:從Linqpad中的結果構建模型
