【发布时间】:2013-06-02 23:02:46
【问题描述】:
我的一位同事不小心从我的数据库中删除了 UserProfiles 表,该表是从模型类生成的。
模型类如下所示:
namespace OneMillion.Models
{
[Table("UserProfile")]
public class User
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
public string UserName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
public string Sex { get; set; }
public string SecretQuestion { get; set; }
public string SecretQuestionAnswer { get; set; }
public int MoneyIn { get; set; }
public int MoneyOut { get; set; }
public int TimesWon { get; set; }
}
}
当我尝试通过包管理器控制台更新数据库时,我收到此错误:
Cannot find the object "dbo.UserProfile" because it does not exist or you do not have permissions.
数据迁移已启用。 我该如何解决这个问题?我要删除整个数据库吗?
【问题讨论】:
标签: asp.net sql asp.net-mvc asp.net-mvc-4 model