I am a beginner in MVC and am trying to add an image to the database and then retrieve it on the front end.
I have added my class:
using System;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Web.Mvc;
namespace TestProject.Data
{
public partial class UpcomingEvent
{
public UpcomingEvent()
{
EventDate = DateTime.Now;
DateTimeStamp = DateTime.Now;
Cancelled = false;
}
[Key]
public int EventID { get; set; }
public DateTime EventDate { get; set; }
public string Title { get; set; }
public string Blurb { get; set; }
public string Body { get; set; }
public byte[] EventImage { get; set; }
public DateTime DateTimeStamp { get; set; }
public bool Cancelled { get; set; }
}
}
And then created a controller with read/write actions using Entity Framework. In the create / edit etc all the fields display other than the image.
What do I need to add to my controller or view in order to send an image to the DB with each entry?