Can someone help please?
I have in my controller the create action:
public class MovieController : Controller
{
Connect connection = new Connect();
Movie movie = new Movie();
[HttpPost]
public ActionResult Create(Movie moviecreated)
{
try
{
// TODO: Add insert logic here
connection.Connection().AddObject(moviecreated);
connection.Connection().Context.SaveChanges();
return RedirectToAction("Index");
}
catch
{
return View(movie);
}
}
}
my connection class
public class Connect
{
public ObjectSet<Movie> Connection()
{
var connStr = ConfigurationManager.ConnectionStrings["Entities"];
ObjectContext context = new ObjectContext(connStr.ConnectionString);
var movieContext = context.CreateObjectSet<Movie>();
return movieContext;
}
}
It is not saving the new addition, what have I got wrong?
Thanks much.
try this: