いくつかの単純なクラスがあります。
最初のクラス:
public class User
{
public int UserId { get; set; }
public string Username { get; set; }
// ...
public ICollection<Topic> Topics { get; set; }
}
2 番目のクラス:
public class Publication
{
public int PublicationId { get; set; }
public string Title { get; set; }
/ ...
public User Author { get; set; }
}
3 番目のクラス:
public class Topic: Publication
{
public string TopicContent { get; set; }
// ...
}
モデルのデータベースを作成した後、データベースの構造は次のようになります。
ユーザー
ユーザーID
ユーザー名
出版物
パブリケーション ID
題名
トピック内容
Author_UserId
User_UserId
ご覧のとおり、テーブル Publications で同一の役割を持つ Author_UserId と User_UserId の 2 つのフィールドを取得します。
Fluent API またはデータ注釈を使用して、このフィールドを 1 つのフィールドにマージするにはどうすればよいですか?