Я пытаюсь создать миграцию для моего простого проекта.Но я получаю следующую ошибку:
C:\RiderProjects\Architecture\Architecture>dotnet ef migrations add init
The 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:
![enter image description here](https://i.stack.imgur.com/xVW6S.png)
более старой версии 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>
БОЛЬШОЕ ОБНОВЛЕНИЕ
Убедитесь, что у вас есть конструктор по умолчанию для класса контекста.