![](/img/trans.png)
[英]Code First Migration - Entity Framework - unable to add column to the table
[英]Most convenient way to alter table (add column) using Entity Framework Code First?
我使用Code First Entity Framework 6.0方法,并具有BaseClass
和一些DerivedClass
es。 我曾经手动更新数据库(所有从BaseClass
派生的表)。
我想1次更新(无论在哪里)数据。
类:
public class IItem {
public int Id {
get;
set;
}
public string Model {
get;
set;
}
public int Cost {
get;
set;
}
//other properties
}
public class MotherBoard : IItem {
public string Manufacturer {
get;
set;
}
public string FormFactor {
get;
set;
}
public string CPUManufacturer {
get;
set;
}
public string Socket {
get;
set;
}
public int SocketCount {
get;
set;
}
//other properties
}
//there are 3 more classes
EF上下文:
public class EFDbContext : DbContext {
public IDbSet<MotherBoard> MotherBoards {
get;
set;
}
public IDbSet<Processor> Processors {
get;
set;
}
public IDbSet<VideoCard> VideoCards {
get;
set;
}
//other
}
您好,您可以为自己的课程和上下文课程发布代码吗?
您正在使用什么版本的EF,以及在什么情况下使用?
您只有一种情况吗? 如果是这样,请在PowerShell中尝试,同时根据您的上下文定位项目
启用迁移
添加迁移初始
更新数据库
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.