如何解决如何将相关实体添加到多对多关系
假设我有这样的实体:
public class Game
{
public int Id { get; set; }
public ICollection<GamePlatform> GamePlatforms { get; set; }
// ↓ This one should be filled ↓
public ICollection<Platform> Platforms { get; set; }
// ↑ This one should be filled ↑
}
public class Platform
{
public int Id { get; set; }
public ICollection<GamePlatform> GamePlatforms { get; set; }
// ↓ This one should be filled ↓
public ICollection<Game> Games { get; set; }
// ↑ This one should be filled ↑
}
public class GamePlatform
{
public int GameId { get; set; }
public Game Game { get; set; }
public int PlatformId { get; set; }
public Platform Platform { get; set; }
}
我想避免创建额外的实体和/或后端代码。 我可以仅通过 OnModelCreating 方法进行配置吗?
解决方法
我认为最佳实践是创建另一个实体。它可以帮助您管理索引和其他内容。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。