When I start my MVC App, this error comes upp "EntityType 'HttpPostedFile' has no key defined"
Can someone please tell me whats wrong here?
Model:
public partial class Advert
{
[Key]
public int ID { get; set; }
[Required]
public HttpPostedFile ImageData { get; set; }
[Required]
public string UrlToUse { get; set; }
[Required]
public string Author { get; set; }
[Required]
public int SchemaType { get; set; }
public string Title { get; set; }
}
When the controller get hit, I run this
public ActionResult DisplayAdvert()
{
db.Database.CreateIfNotExists();
return PartialView("_Advert");
}
And boom, at the line db.Database.CreateIfNotExists(); it fails:
Boat_Club.Models.HttpPostedFile: : EntityType 'HttpPostedFile' has no key defined. Define the key for this EntityType. HttpPostedFiles: EntityType: EntitySet 'HttpPostedFiles' is based on type 'HttpPostedFile' that has no keys defined.
I've searched for some answers, and all says that I have to add [Key] to the Model, and I have, so what is going on here??
I'm using Visual Studio Express 2013 for Web, with all the latets versions of MVC and EF.
/Thanks
This works though!!
public partial class Advert
{
[Key]
public int ID { get; set; }
[Required]
public byte[] ImageData { get; set; }
[Required]
public string UrlToUse { get; set; }
[Required]
public string Author { get; set; }
[Required]
public int SchemaType { get; set; }
public string Title { get; set; }
}