相关疑难解决方法(0)

执行迁移EF core 2.0时出错,将Identity id从string更改为int

场景:

我从同事那里收到了ASP.NET CORE中的自动生成项目.帐户/管理服务有自动生成的代码.此代码包括ApplicationUser Class,DBContext和迁移文件夹,其中包含00000000000000_CreateIdentitySchema.cs和20180323155805_Snapshot.cs.我一直在尝试将我的User类更改为具有整数id.为此,我在IdentityUser中添加了泛型:

public class ApplicationUser : IdentityUser**<int>**
{
}
Run Code Online (Sandbox Code Playgroud)

我还必须创建ApplicationRole类,因为它在迁移文件中创建之前.

public class ApplicationRole : IdentityRole<int>
{
}
Run Code Online (Sandbox Code Playgroud)

我也改变了我的背景:

public class ApplicationDbContext : IdentityDbContext<ApplicationUser, 
    **ApplicationRole, int**>
Run Code Online (Sandbox Code Playgroud)

在迁移文件中,创建了登录方案.添加更改后,我添加了新的迁移.在添加迁移期间,我收到此错误:

要更改列的IDENTITY属性,需要删除并重新创建列.

migration identity ef-migrations entity-framework-core asp.net-core-mvc

7
推荐指数
1
解决办法
3445
查看次数