2013-06-02 121 views
0

我的一個同事從我的數據庫意外刪除了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. 

數據遷移啓用。 我該如何解決這個問題?我應該刪除整個數據庫嗎?

回答

0

您是否可以以具有足夠權限創建數據庫的用戶連接到數據庫?您可以在SSMS中以該用戶身份登錄並使用適當的列創建表等,然後表存在,並且遷移可以找到它。