Невозможно создавать миграции в Entity Framework CoreC#

Место общения программистов C#
Ответить
Anonymous
 Невозможно создавать миграции в Entity Framework Core

Сообщение Anonymous »

Кажется, я могу создавать миграции с помощью этой команды:

Код: Выделить всё

dotnet ef migrations add InitialCreate --output-dir data\Migrations
Вот какая ошибка:

Код: Выделить всё

Build started...
Build succeeded.
The Entity Framework tools version '8.0.10' is older than that of the runtime '9.0.0-rc.2.24474.1'. Update the tools for the latest features and bug fixes. See https://aka.ms/AAc1fbw for more information.
Unable to create a 'DbContext' of type 'RuntimeType'. The exception 'Unable to resolve service for type 'Microsoft.EntityFrameworkCore.DbContextOptions`1[GameStore.data.GameStoreContext]' while attempting to activate 'GameStore.data.GameStoreContext'.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
Мой файл .csproj:

Код: Выделить всё



net8.0
enable
enable




runtime; build; native; contentfiles; analyzers; buildtransitive
all






Код: Выделить всё

GameStoreContext.cs:
using System;
using GameStore.Entities;
using Microsoft.EntityFrameworkCore;

namespace GameStore.data
{
public class GameStoreContext(DbContextOptions options) : DbContext(options)
{

// DbSets representing tables in your database
public DbSet Games { get; set; }
public DbSet Genres { get; set; }
}
}

Код: Выделить всё

appsettings.json:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"GameStore": "Data Source=GameStore.db"
}
}
SQLite3 не распознается интегрированным терминалом VS Code, но отлично работает в cmd

Подробнее здесь: https://stackoverflow.com/questions/790 ... ework-core
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»