public class Autor
{
[Key]
public int AutorID { get; set; }
[Required]
[MaxLength(100)]
public string Nome { get; set; }
[Required]
[Display(Name = "Data de nascimento")]
[DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
public DateTime Data { get; set; }
public virtual ICollection<Livro> Livros { get; set; }
}
I made a controller based on this class. It all works fine.
But after i tried to add one property to the model. I addedd a string
public string test { get; set; } but i didnt change anything on the Views
But now i got an error here
public ActionResult Index()
{
return View(db.Autores.ToList());
}
Does anybody know what is happening. I thought that it should work because string is a nullable property.
anderson7777
Member
141 Points
279 Posts
I had an error in runtime
Jan 27, 2013 01:54 PM|LINK
I have code like this:
public class Autor { [Key] public int AutorID { get; set; } [Required] [MaxLength(100)] public string Nome { get; set; } [Required] [Display(Name = "Data de nascimento")] [DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)] public DateTime Data { get; set; } public virtual ICollection<Livro> Livros { get; set; } }I made a controller based on this class. It all works fine.
But after i tried to add one property to the model. I addedd a string
public string test { get; set; } but i didnt change anything on the Views
But now i got an error here
public ActionResult Index() { return View(db.Autores.ToList()); }Does anybody know what is happening. I thought that it should work because string is a nullable property.
thx in advance
Anderson
francesco ab...
All-Star
20888 Points
3277 Posts
Re: I had an error in runtime
Jan 27, 2013 03:57 PM|LINK
Which error? You added a property to what? To the Autor class?
Please show theerror you get, the modified class, and the View
Mvc Controls Toolkit | Data Moving Plug-in Videos
anderson7777
Member
141 Points
279 Posts
Re: I had an error in runtime
Jan 27, 2013 09:45 PM|LINK
I am sorry I am starting to make my own MVC projects now
I already saw my mistake, i wasnt updating the model