I 3表:用户, Ref_League_name 和联结表 User_Leauge 我的用户表存储用户数据。我想创建一个表单,在用户登录后,该用户可以使用其用户ID选择联赛。我还想在User_league表中存储userID和LeagueID(用户选择的)。如何创建控制器和User_league的视图以更新联结表(User_league)中的userID和LeagueID? 这是代码:
用户表:
namespace NFL_WebApplication_V2.Models
{
using System;
using System.Collections.Generic;
public partial class User
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public User()
{
this.User_League = new HashSet<User_League>();
}
public int UserID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string EmailID { get; set; }
public Nullable<System.DateTime> DOB { get; set; }
public string PWS { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<User_League> User_League { get; set; }
}
Ref_league_name
namespace NFL_WebApplication_V2.Models
{
using System;
using System.Collections.Generic;
public partial class Ref_League_name
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Ref_League_name()
{
this.User_League = new HashSet<User_League>();
}
public int LeagueID { get; set; }
public string LeagueName { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<User_League> User_League { get; set; }
}
}
User_league
namespace NFL_WebApplication_V2.Models
{
using System;
using System.Collections.Generic;
public partial class User_League
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public User_League()
{
this.UserLeague_Week = new HashSet<UserLeague_Week>();
}
public int ID { get; set; }
public int UserID { get; set; }
public int LeagueID { get; set; }
public virtual Ref_League_name Ref_League_name { get; set; }
public virtual User User { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<UserLeague_Week> UserLeague_Week { get; set; }
}
}
请帮助,我是MVC新手,非常感谢