@Mootfrost
C#, C++, JS, Python

Почему не создается миграция dotnet ef?

есть файл:
using System;
using Microsoft.EntityFrameworkCore;
using MyShop.Models;
using Microsoft.EntityFrameworkCore.Design;


namespace  MyShop.Data
{
    public class ApplicationDbContext: DbContext
    {
        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) :
            base(options)
        {

        }

        public DbSet<Category> Category { get; set; }
    }
}


После:
dotnet ef migrations add CategoryToDatabase
Создался:
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace MyShop.Migrations
{
    public partial class CategoryToDatabase : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Category",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    DisplayOrder = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Category", x => x.Id);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Category");
        }
        
    }
}


Потом я выполнил:
dotnet ef database update
Build succeeded, но бд не обновляется вообще никак.
В appsettings:
{
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Database=MyShop;Trusted_Connection=True;User Id=SA,Password=P@ssswo1rd"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*"
}

Причем абсолютно не важно, если я ломаю connectionstring.
Попробовал выполнить с -v:
spoiler
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 6.0.10 initialized 'ApplicationDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer:6.0.10' with options: None
Finding design-time services referenced by assembly 'MyShop'...
Finding design-time services referenced by assembly 'MyShop'...
No referenced design-time services were found.
Finding design-time services for provider 'Microsoft.EntityFrameworkCore.SqlServer'...
Using design-time services from provider 'Microsoft.EntityFrameworkCore.SqlServer'.
Finding IDesignTimeServices implementations in assembly 'MyShop'...
No design-time services were found.

Причем на других компах это похоже работает без проблем
  • Вопрос задан
  • 99 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы