亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

未能創建遷移。EF Core 工具比某些版本舊

未能創建遷移。EF Core 工具比某些版本舊

C#
慕桂英546537 2022-10-15 14:12:44
我正在嘗試為我的簡單項目創建一個初始化遷移。但我收到下一個錯誤:C:\RiderProjects\Architecture\Architecture>dotnet ef migrations add initThe EF Core tools version '2.1.8-servicing-32085' is older than that of the runtime '2.2.2-servicing-10034'. Update the tools for the latest features and bug fixes.Unable to create an object of type 'DomainContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728這沒有任何意義,因為如果我們看看我的 NuGet 依賴項:沒有較舊的 Core.Tools 版本 - 它是 2.2.2。這是我的 Context 類(也許問題隱藏在這個類中):public class DomainContext : DbContext{    private readonly IConfiguration _configuration;    public DomainContext(IConfiguration configuration)    {        _configuration = configuration;    }    public DbSet<Car> Car { get; set; }    public DbSet<Company> Company { get; set; }    public DbSet<Location> Location { get; set; }    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)    {        if (!optionsBuilder.IsConfigured)        {            optionsBuilder.UseSqlServer(_configuration.GetConnectionString("DefaultConnection"));        }    }    protected override void OnModelCreating(ModelBuilder modelBuilder)    {        modelBuilder.Entity<Company>(CompanyMapping.Config);    }}有人可以提出解決方案嗎? 編輯 這是.csproj文件: <ItemGroup>      <PackageReference Include="EntityFramework" Version="6.2.0" />      <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.2" />      <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.6" />      <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.2" />      <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />      <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />      <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />      <PackageReference Include="SimpleInjector" Version="4.4.3" />    </ItemGroup>大更新確保您有 Context Class 的默認構造函數。
查看完整描述

1 回答

?
互換的青春

TA貢獻1797條經驗 獲得超6個贊

查看您的 .csproj 文件。PackageReference 節點中可能有一個較舊的版本。



查看完整回答
反對 回復 2022-10-15
  • 1 回答
  • 0 關注
  • 97 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號