有几个简单的类:
第一课:
public class User
{
public int UserId { get; set; }
public string Username { get; set; }
// ...
public ICollection<Topic> Topics { get; set; }
}
第二类:
public class Publication
{
public int PublicationId { get; set; }
public string Title { get; set; }
/ ...
public User Author { get; set; }
}
第三类:
public class Topic: Publication
{
public string TopicContent { get; set; }
// ...
}
为我的模型创建数据库后,我有以下数据库结构:
用户
用户身份
用户名
出版物
出版物编号
标题
主题内容
Author_UserId
User_UserId
如您所见,我得到两个字段 Author_UserId 和 User_UserId 在表 Publications 中具有相同的角色。
如何使用 Fluent API 或 Data Annotation 将这些字段合并为一个字段?