1
我正在使用MVC4 Internet应用程序,并试图更改帐户模型以使用我的上下文。我似乎无法得到它的工作。我试图删除上下文,并在我的上下文中包含用户配置文件,我可以登录等,但当我通过用户id检查配置文件时,它会返回空值。更改用户上下文
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;
}
我得到一个空值回报。任何人都知道如何在不同的环境下成功使用简单的会员资格?
你使用哪一部分 – 2013-03-25 02:08:24
刚刚从零开始,固定它。 – 2013-03-28 21:08:01