MVC4インターネットアプリケーションを使用していて、コンテキストを使用するようにアカウントモデルを変更しようとしています。私はそれを機能させることができないようです。コンテキストを削除してユーザープロファイルをコンテキストに含めようとしましたが、ログオンなどできましたが、ユーザーIDでプロファイルを確認すると、null値が返されます。
public DbSet<FightCard> FightCards { get; set; }
public DbSet<Fight> Fights { get; set; }
public DbSet<Fighter> Fighters { get; set; }
public DbSet<UserProfile> UserProfiles { get; set; }
[Table("UserProfile")]
public class UserProfile
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
public string UserName { get; set; }
}
私がこれをやろうとすると:
public ActionResult Profile(int id)
{
UserProfile profile = uc.UserProfiles.Find(id);
ViewBag.Name = profile.UserName;
}
null値が返されます。単純なメンバーシップを別のコンテキストでうまく使用する方法を知っている人はいますか?