在我完成我的应用程序的 SimpleMembership 步骤后,还有另一个问题......
namespace Korbball.Models
{
public class GamesContext : DbContext
{
public GamesContext()
: base("KorbballDBContext")
{
}
public DbSet<Games> Games { get; set; }
public DbSet<Teams> Teams { get; set; }
}
public class Games
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int GameId { get; set; }
public int TeamA { get; set; }
public int TeamB { get; set; }
public int ResultA { get; set; }
public int ResultB { get; set; }
public int League { get; set; }
public DateTime StartDate { get; set; }
public Boolean Finished { get; set; }
}
public class Teams
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int TeamId { get; set; }
public string TeamName { get; set; }
}
}
我的目标是创建带有结果的游戏等。TeamA 和 TeamB 列应该是 Teams 表中的 TeamID。
我必须采取哪些步骤来设置正确的关系。
附加信息:
游戏桌 ->
GamesID = 1
TeamA = 1
TeamB = 2
ResultA = 10
ResultB = 8
团队表->
TeamId = 1
TeamName = "Manchester"
TeamId = 2
TeamName = "Zurich"
在视图上->
Manchester 10 : 8 Zurich