我已經創建了我的模型,但whem我想添加一個新的attribut,總是出現這樣的錯誤:如何在ASP中添加一個新的attribut在你的模型類的MVC
Severity Code Description Project File Line Suppression State
Error CS1519 Invalid token '}' in class, struct, or interface member declaration CarManagement C:\Users\aganfoud\Documents\Visual Studio 2015\Projects\CarManagement\CarManagement\Models\Voiture.cs 33 Active
這是我的模型:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
namespace CarManagement.Models
{
public class Voiture
{
public int ID { get; set; }
[StringLength(60, MinimumLength = 3)]
[Required]
public string Marque { get; set; }
[Required]
[StringLength(30)]
public string Modele { get; set; }
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true) Display(Name = "Construction Date")
DataType(DataType.Date)]
public DateTime ConstructionDate { get; set; }
[Required]
[Range(1, 99999)]
[DataType(DataType.Currency)]
public decimal Price { get; set; }
public string Color { get; set; }
[Required]
[StringLength(30)]
}
}
,當我想要添加的attribut 顏色,如果沒有這個attribut出現錯誤,他的作品完美
嘗試把上述特性的屬性 –
你也是一個「」在失蹤在ContructinDate上結合屬性。可能是複製/發佈錯誤。 –
謝謝,它的工作原理沒有這個「」我不知道問題所在,怎麼我現在有一個例外puting上述屬性後: 類型的異常‘System.Data.Entity.Core.EntityCommandExecutionException’發生的EntityFramework。 SqlServer.dll但沒有在用戶代碼 – Anouar