私はこれに非常に慣れていないので、この問題について助けを求めています。
まず、私はすでにデータベースを持っています。たとえば、このデータベースにはUser、UserMapping、UserRoleの3つのテーブルがあります。次のように3つのクラスのモデルを生成しました。
public class user
{
public int UserID { get; set; }
public string UserName { get; set; }
public virtual ICollection<UserMapping> UserMappings { get; set; }
}
public class UserMapping
{
public int UserMappingID { get; set; }
public int UserID { get; set; }
public int UserRoleID { get; set; }
public virtual User User { get; set; }
public virtual UserRole UserRole { get; set; }
}
public class UserRole
{
public int UserRoleID { get; set; }
public string RoleName { get; set; }
public virtual ICollection<UserMapping> UserMappings { get; set; }
}
新しいユーザーを作成し、新しいユーザーのユーザーロールを追加したいと思います。ユーザーとユーザーロールには直接の関係はありません。強く型付けされたUserモデルクラスを使用して、新しいユーザーを作成するためのビューを作成したいと思います。このビューでユーザーのユーザーロールを作成するにはどうすればよいですか?
助けてください...!事前にどうもありがとうございました。