0

I am working on a User registration form in MVC. Using the Entity framework , I linked my database with the project by creating an ADO model. As a part of saving the data to the table, I added a Httppost method in the controllet. Below is the snippet:

[HttpPost]
public ActionResult registration(u_user usermodel)
{
    using (InCredibleModel models = new InCredibleModel())
    {
        models.u_user.Add(usermodel);
        models.SaveChanges();
    }
    ModelState.Clear();
    ViewBag.SuccessMessage = "Sign Up successfull!!!";
    return View("Registration", new u_user());
}

Here InCredibleModel is the name of the data model that I created when linking my database. But this model is treated type/namespace and it is throwing me "Type/namespace could not be found" error. How to fix this?

Arjan Einbu
  • 13,543
  • 2
  • 56
  • 59
Jiah
  • 93
  • 2
  • 13
  • You need to add the namespace of `InCredibleModel` wherever you use it. like this: `using ProjectName.Models.FolderName`. – adiga Oct 06 '17 at 20:11
  • @adiga already added – Jiah Oct 06 '17 at 20:16
  • are you getting the error in the `controller` or the `View`? The title says view and you've posted the controller code. – adiga Oct 06 '17 at 20:17
  • @adiga sorry fixed it. throws in controller :( – Jiah Oct 06 '17 at 20:27
  • Is `InCredibleModel` in a different project? If yes, you can remove the project reference and add again. [See this question as well](https://stackoverflow.com/questions/4764978/the-type-or-namespace-name-could-not-be-found/26373745) – adiga Oct 06 '17 at 20:48
  • Incrediblemodel is the DB model name. Project name is InCredible_portal. – Jiah Oct 06 '17 at 21:02

0 Answers0