[英]ICollection<T> will not be added as a field in the Entity Framework, Why?
public class User
{
[Key]
public string userID { get; set; }
public string username { get; set; }
public virtual ICollection<Log> logs { get; set; }
public User() { }
}
This is my class that I use for my DbSet<User>
but the initial migration only picks up the userID and userName 这是我用于
DbSet<User>
类,但是初始迁移仅使用userID和userName
public override void Up()
{
CreateTable(
"dbo.Logs",
c => new
{
logID = c.String(nullable: false, maxLength: 128),
logString = c.String(),
logDatetime = c.DateTime(nullable: false),
User_userID = c.String(maxLength: 128),
})
.PrimaryKey(t => t.logID)
.ForeignKey("dbo.Users", t => t.User_userID)
.Index(t => t.User_userID);
CreateTable(
"dbo.Users",
c => new
{
userID = c.String(nullable: false, maxLength: 128),
username = c.String(),
})
.PrimaryKey(t => t.userID);
}
So because it does not make that field, I cannot add to the logs because its non-existent can anyone explain to me how to get the table to add the ICollection<Logs> logs
? 因此,因为它不构成该字段,所以我无法添加到日志中,因为任何人都无法向我解释如何获取该表以添加
ICollection<Logs> logs
?
ICollection logs is not a field. ICollection日志不是一个字段。 It is an in memory collection that gets populated from the logs table.
它是一个从日志表填充的内存中集合。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.