This questions seems to have been answered before, but those answers don't work in my case as far as I know, since the codes in the previous questions were much different than my code.
I'm very new at MVC by the way.
This is the error I get:
Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
Controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SimpleMVC.Models;
namespace SimpleMVC.Controllers
{
public class AdminController : Controller
{
// GET: Admin
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult AddMovie(string Title, int Price)
{
using (MovieDb_Entities db = new MovieDb_Entities()){
Movies item = new Movies();
item.Title = Title;
item.Price = Price;
db.Movies.Add(item);
db.SaveChanges();
}
return RedirectToAction("Index");
}
public ActionResult Hey()
{
return View();
}
}
}
Partial view:
<p>Add new movie</p>
<form method="post" action="/Admin/AddMovie">
<input type="text" name="Title" placeholder="Title" /><br />
<input type="text" name="Price" placeholder="Price" /><br />
<input type="submit" value="Add Movie" />
</form>
Thank you in advance.