title: Casting Object type in mvc controller
body: <p>I have the folowing class and controller (mvc)</p>
  
  <p>UI Model inherits DB model (ef4.0)</p>
  
  <pre><code>public class RegistrationModel : Model.User
      {
          [Required]
          public string PasswordText { get; set; }
      }   
  </code></pre>
  
  <p>MVC controller</p>
  
  <pre><code>    public ActionResult Create(RegistrationModel registrationModel)
              {
                  try
                  {
                      Context ctx = new Context();
                      Model.User user = new Model.User();
                      user = (registrationModel as Model.User);
                      user.Password = System.Text.ASCIIEncoding.ASCII.GetBytes(registrationModel.PasswordText); //do encryption later on
  ...
                      ctx.Customer.Add(registrationModel as Model.User);
                      ctx.SaveChanges();
                  }
      }
  </code></pre>
  
  <p>when i cast the registrationmodel to a user the type remains registrationmodel is there a way to cast it, without copying all its properties to a new user object?</p>
  
  <pre><code>                Model.User user = new Model.User();
                  user.Active = registrationModel.Active;
                  user.Blocked = registrationModel.Blocked;
  //...
  </code></pre>
  
  <p>....</p>