小编Jeb*_*eng的帖子

Entity Framework Core:表“Users”中的列“Id”的类型无法用作索引中的键列

它在 SQLite 下工作

数据库上下文.cs

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

    public DbSet<User> Users { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

用户.cs

public class User : OAuthUser
{
    public string FullName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

OAuthUser.cs

public class OAuthUser
{
    public string Id { get; set; }

    public string Email { get; set; }

    public string UserName { get; set; }

    public string PhoneNumber { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

然后我执行了Add-Migration和Database-Update。它应该更新到我机器上的 SQLServer …

c# entity-framework-core

6
推荐指数
2
解决办法
5530
查看次数

标签 统计

c# ×1

entity-framework-core ×1