比如 User表,我想要将User表拆分成两个实体类,如何实现entity framework的映射
//现在的User表结构 public class User { public int UserID { get; set; } public string UserName { get; set; } public string QQ { get; set; } public string MSN { get; set; } public string Mobile { get; set; } } //拆分成两个实体类 public class User { public int UserID { get; set; } public string UserName { get; set; } public UserInfo Info { get; set; } } //拆分成两个实体类 public class UserInfo { public string QQ { get; set; } public string MSN { get; set; } public string Mobile { get; set; } }
//拆分成两个实体类 public class User { public int UserID { get; set; } public string UserName { get; set; } public UserInfo Info { get; set; } } //拆分成两个实体类 [ComplexType] public class UserInfo { public string QQ { get; set; } public string MSN { get; set; } public string Mobile { get; set; } }
一提问就找到办法了,加个[ComplexType]标签就ok了,就这么简单,哈哈
参考资料