I have a model:

public class User
    public int ID { get;set; }
    public string userName { get;set; }
    public string userPassword { get;set; }
    public string userEmail { get;set; }

and an example viewmodel:

public class UserViewModel
    public int ID { get; set; }

    [DisplayName("User Name")]
    public string userName { get; set; }
    public string userPassword { get; set; }
    public string userEmail { get; set; }

and a create action:

public ActionResult Create(UserViewModel u)
    //user.ID = u.ID;
    user.userEmail = u.userEmail;
    user.userName = u.userName;
    user.userPassword = u.userPassword;


    return View();

So now I want to add only my model to the database but if I create a View then Visual Studio keeps adding this to the context:

   public System.Data.Entity.DbSet<ProjectManagement.ViewModels.UserViewModel> UserViewModels { get; set; }

..which creates an additional empty table in the database. Why is that? What I should do if I want to separat model and ViewModel with validation, data, etc.?

Related posts

Recent Viewed