Asp.net 如何启动迁移EF Core

Asp.net 如何启动迁移EF Core,asp.net,entity-framework,asp.net-core,entity-framework-core,asp.net-core-mvc,Asp.net,Entity Framework,Asp.net Core,Entity Framework Core,Asp.net Core Mvc,我有几个解决方案项目。基础设施项目中有一个dbContext,我想迁移,但出现了一个错误。请告诉我我做错了什么,我怎样才能纠正它 使用Infrastructure.Models; 使用Microsoft.EntityFrameworkCore; 命名空间基础结构 { 公共类ApplicationDbContext:DbContext { 公共应用程序DBContext(DbContextOptions选项) :基本(选项) { } 公共数据库集事件{get;set;} 配置时受保护的覆盖无效

我有几个解决方案项目。基础设施项目中有一个dbContext,我想迁移,但出现了一个错误。请告诉我我做错了什么,我怎样才能纠正它

使用Infrastructure.Models;
使用Microsoft.EntityFrameworkCore;
命名空间基础结构
{
公共类ApplicationDbContext:DbContext
{
公共应用程序DBContext(DbContextOptions选项)
:基本(选项)
{
}
公共数据库集事件{get;set;}
配置时受保护的覆盖无效(DBContextOptions Builder Options Builder)
{
使用npgsql(GetConnectionString());
}
私有静态字符串GetConnectionString()
{
常量字符串databaseName=“myDb”;
const string databaseUser=“postgres”;
常量字符串databasePass=“root”;
返回$“Server=localhost;”+
$“数据库={databaseName};”+
$“uid={databaseUser};”+
$“pwd={databasePass};”+
$“pooling=true;”;
}
}    
}

您必须将不带参数的构造函数添加到类
ApplicationDbContext

错误图像上的链接清楚地描述了这一点:

using Infrastructure.Models;
using Microsoft.EntityFrameworkCore;

namespace Infrastructure
{
    public class ApplicationDbContext : DbContext
    {
        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
        : base(options)
        {
        }

        public DbSet<EventModel> Event { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseNpgsql(GetConnectionString());
        }

        private static string GetConnectionString()
        {
            const string databaseName = "myDb";
            const string databaseUser = "postgres";
            const string databasePass = "root";

            return $"Server=localhost;" +
                   $"database={databaseName};" +
                   $"uid={databaseUser};" +
                   $"pwd={databasePass};" +
                   $"pooling=true;";
        }
    }    
}