2013-11-27 71 views
0

我得到這個生成錯誤:模型後MVC不重建改變

Compiler Error Message: CS1061: 'Timesheet.Models.Time' does not contain a definition for 'Hours' and no extension method 'Hours' accepting a first argument of type 'Timesheet.Models.Time' could be found (are you missing a using directive or an assembly reference?) 
... 
Line 36:     <td class="text-right">@String.Format("{0:N2}", client.Projects.SelectMany(project => project.Times).Sum(time => time.Hours))</td> 

儘管在模型中有這樣的:

public Decimal Hours 
{ 
    get 
    { 
     return Convert.ToDecimal(Convert.ToDateTime(Minutes).TotalHours); 
    } 
} 

基本上,我剛剛更換了啓動&結束時間與分鐘字段,並更新小時定義使用分鐘,而不是從開始&結束時間計算(並將其從小時分鐘重新命名爲剛好幾小時)。但是模型中的這些變化並不是「正確構建」的。

事實上,如果我檢查模型的第36行上的智能感知,我會看到舊的字段。如果我在HoursSpent上按F12,它會將我帶到「Time [from metadata]」,而不是Time模型。所以這個構建不會構建。

+0

難道你不需要一個安裝員幾小時,因爲總和? –

+0

你能提供整個時間模型嗎? –

回答

0

我認爲這個問題是我從本地IIS打開了這個項目,而且有點棘手。我重新啓動並從文件系統重新打開,似乎解決了這個問題。