我有一些共享会员数据库的Web应用程序。我使用SimpleMembershipProvider
。我在Firstname
表格中添加了列Lastname
和UserProfile
。我需要其中一个应用程序中的Firstname和Lastname信息。我有一个帮助方法,将信息填充到SuggestionVM视图模型中。
private SuggestionVM PopulateSuggestionVM(Suggestion suggestion)
{
UsersContext userContext = new UsersContext();
var user = userContext.UserProfiles.FirstOrDefault(u => u.UserId == suggestion.UserId);
var name = "";
if (user != null)
{
name = user.Firstname + " " + user.Lastname;
}
SuggestionVM suggestionvm = new SuggestionVM()
{
Id = suggestion.Id,
Title = suggestion.Title,
Comment = suggestion.Comment,
UserId = suggestion.UserId,
Name = name,
IsAnynomous = (suggestion.UserId == null) ? true : false,
SubmittedDate = suggestion.SubmittedDate
};
return suggestionvm;
}
上述方法在Suggestion controller的Index方法中调用。
public ActionResult Index()
{
List<SuggestionVM> suggestionvms = new List<SuggestionVM>();
var suggestions = db.Suggestions.ToList();
foreach(var suggestion in suggestions)
{
SuggestionVM suggestionvm = PopulateSuggestionVM(suggestion);
suggestionvms.Add(suggestionvm);
}
return View(suggestionvms);
}
每当我运行它时,我都会收到以下错误:
Invalid object name 'dbo.UserProfile'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'dbo.UserProfile'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
导致错误的原因是什么?