我正在尝试为我的简单项目创建一个初始化迁移。但我收到下一个错误: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
提交
取消