I am creating mvc4 web where I need to login or register at same view page (as per design). And I am using EntityFramework. I am able to store my data and even retrieve them but
view form does not shows validation(as I am using Model Which contains two more models plz check the model for details)
I want my view form to show validation errors such as "Email Field is Required" which is suppose to happen automatically by Framework. please help...

HomeController.cs
-----------------

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LoginOrRegisterDemo.Models;

namespace LoginOrRegisterDemo.Controllers
{
public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View();
    }

    public void Register(User user)
    {
        //Models.User user = new Models.User();
        //TryUpdateModel(user);
        UserContext userContext = new UserContext();
        userContext.users.Add(user);
        userContext.SaveChanges();
        Response.Redirect("Show_Users");
    }
    public ActionResult Show_Users()
    {
        UserContext userContext= new UserContext();
        IEnumerable<User> users = userContext.users.ToList();

        return View(users);
    }
}
}

```

ViewForms are
-------------

Index.cshtml
------------

```
@model LoginOrRegisterDemo.Models.UserModel

@{
    ViewBag.Title = "Index";
}
@using (Html.BeginForm("Login","Home")) {
@Html.ValidationSummary(true)

<fieldset>
    <legend>IUser</legend>

    <div class="editor-label">
        @Html.LabelFor(model => model.iuser.EmailId)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.iuser.EmailId)
        @Html.ValidationMessageFor(model => model.iuser.EmailId)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.iuser.Password)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.iuser.Password)
        @Html.ValidationMessageFor(model => model.iuser.Password)
    </div>

    <p>
        <input type="submit" value="Create" />
    </p>
</fieldset>
}
@using (Html.BeginForm("Register","Home")) {
@Html.ValidationSummary(true)

<fieldset>
    <legend>User</legend>

    <div class="editor-label">
        @Html.LabelFor(model => model.user.EmailId)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.user.EmailId)
        @Html.ValidationMessageFor(model => model.user.EmailId)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.user.Name)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.user.Name)
        @Html.ValidationMessageFor(model => model.user.Name)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.user.Password)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.user.Password)
        @Html.ValidationMessageFor(model => model.user.Password)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.user.Gender)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.user.Gender)
        @Html.ValidationMessageFor(model => model.user.Gender)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.user.City)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.user.City)
        @Html.ValidationMessageFor(model => model.user.City)
    </div>

    <p>
        <input type="submit" value="Create" />
    </p>
</fieldset>
}

<div>
@Html.ActionLink("Back to List", "Show_Users")
</div>

```

My Index Page Contains two fieldset one for login and another for Registration

Show\_Users.cshtml
------------------

```
@model IEnumerable<LoginOrRegisterDemo.Models.User>

@{
ViewBag.Title = "Show_Users";
}

<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
    <th>
        @Html.DisplayNameFor(model => model.EmailId)
    </th>
    <th>
        @Html.DisplayNameFor(model => model.Name)
    </th>
    <th>
        @Html.DisplayNameFor(model => model.Password)
    </th>
    <th>
        @Html.DisplayNameFor(model => model.Gender)
    </th>
    <th>
        @Html.DisplayNameFor(model => model.City)
    </th>
    <th></th>
</tr>

@foreach (var item in Model) {
<tr>
    <td>
        @Html.DisplayFor(modelItem => item.EmailId)
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.Name)
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.Password)
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.Gender)
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.City)
    </td>
    <td>
        @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
        @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
        @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
    </td>
</tr>
}
</table>
<div>
@Html.ActionLink("Back to Index", "Index")
</div>

```

And Models are:-
----------------

User.cs File
------------

```
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace LoginOrRegisterDemo.Models
{
public class User : IUser
{
    [Key]
    [Required]
    public String EmailId { get; set; }
    [Required]
    public String Name { get; set; }
    [Required]
    public String Password { get; set; }
    [Required]
    public String Gender { get; set; }
    [Required]
    public String City { get; set; }
}
public class IUser
{
    [Required]
    public String EmailId { get; set; }
    [Required]
    public String Password { get; set; }
}
public class UserModel
{
    //public IEnumerable<LoginOrRegisterDemo.Models.User> users { get; set; }
    public User user;
    public IUser iuser;
}
}

```

UserContext.cs
--------------

```
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Data;

namespace LoginOrRegisterDemo.Models
{
public class UserContext : DbContext
{
    public DbSet<User> users
    {
        get;
        set;
    }
}
}

```