找不到方法:"Void Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator..ctor(Microsoft.EntityFramewo



我正在创建一个有3个项目的解决方案,一个用于EF Core,一个用于数据库,最后一个用于API。API是启动项目。我正试图从数据库项目构建迁移。这个迁移应该创建Identity的包内置的User表。然而,我一直收到上面的错误。

我所有的项目都是ASP。Core 5.0

我使用的包是:

对于DB项目:

* EntityFrameWorkCore

* EntityFrameWorkCore。工具

*Install-Package柚。entityframeworkcore . mysql -Version 5.0.0-alpha.2

* Microsoft.AspNetCore.Identity

* Microsoft.AspNetCore.Identity.EntityFrameworkCore

对于API项目:

* EntityFrameWorkCore。设计>

在API启动项目 中引用了DB项目在API项目中,我做了以下更改:

到Startup.cs

public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
//To Connect to MySQL:
string mySqlConnectionStr = Configuration.GetConnectionString("DefaultConnection");
services.AddDbContextPool<DBAccessContext>(options => options.UseMySql(mySqlConnectionStr, ServerVersion.AutoDetect(mySqlConnectionStr)));
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Wasel.API", Version = "v1" });
});
}

到appsetting.json:

{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
//Connection String for MySQL
"ConnectionStrings": {
"DefaultConnection": "server=localhost; port=3306; database=my_DB; user=root; password=123456; Persist Security Info=False; Connect Timeout=300"
}
}
最后我的DBAccessContect是:
public class DBAccessContext : IdentityDbContext<User>
{
public DBAccessContext (DbContextOptions<DBAccessContext> options) : base(options)
{
}
}

where user =

public class User : IdentityUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
}

我通过将我所有的框架包从6.0.0预览版本降级到5.0.3稳定版本来解决这个错误

相关内容

最新更新