我正在嘗試為我的簡單項目創建一個初始化遷移。但我收到下一個錯誤: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 的默認構造函數。
添加回答
舉報
0/150
提交
取消