【发布时间】:2020-11-09 19:23:16
【问题描述】:
我想创建一个包含这两个实体类关系的数据库表。迁移后我看不到关系表,只有我的 db set 表。我将在下面分享代码。
这是一个实体,
public class Server:IEntity
{
[Key]
public int ServerId { get; set; }
public string ServerPassword { get; set; }
// public List<AppUser> UserId { get; set; } do not necessary
public string ServerName { get; set; }
public DateTime ModifiedDate { get; set; }
public DateTime CreateDate { get; set; }
}
这是另一个
public class Project:IEntity
{
public string ProjectName { get; set; }
public int ProjectId { get; set; }
public int ServerId { get; set; }
public virtual Server Server { get; set; }
}
还有我的 Dbset 类
public class AppIdentityDbContext : IdentityDbContext<AppUser, AppRole, string>
{
public AppIdentityDbContext(DbContextOptions<AppIdentityDbContext> options) : base(options)
{
}
public DbSet<Server> Servers { get; set; }
public DbSet<Project> Projects { get; set; }
}
【问题讨论】:
标签: c# .net asp.net-core asp.net-mvc-3 model-view-controller