它在 SQLite 下工作
数据库上下文
public class DbContext : DbContext
{
public DbContext(DbContextOptions<DbContext> options) : base(options)
{
}
public DbSet<User> Users { get; set; }
}
用户.cs
public class User : OAuthUser
{
public string FullName { get; set; }
}
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; }
}
然后我执行了Add-Migration
和Database-Update
。它应该更新到我机器上的 SQLServer 但它记录了这个错误:
表 'Users' 中的列 'Id' 的类型不能用作索引中的键列。无法创建约束或索引。请参阅以前的错误。
我想Id
在OAuthUser.cs
作为主键,但有错误
更改数据库服务时需要删除所有迁移。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句