title: convert one type to another in MVC
body: <p>I have two references:</p>
  
  <ul>
  <li>in <code>.Core</code> reference I have one class with business functions. </li>
  <li>in another one - models, views and controllers. </li>
  </ul>
  
  <p>I want to make a simple <code>Crete</code> function, but can not convert types.</p>
  
  <pre><code>//my model in .Core:
  
  public class A
  { 
      public int id { get; set; }
      public string name { get; set; }
      public string address { get; set; }
      public string phone { get; set; }
  }
  
  //my Business function in .Core:
  
  public void Add(A a)
      {
          using (My_Entities context = new My_Entities())
          {
              context.tS.Add(a);
              context.SaveChanges();
          }
      }
  
  
  
  //My ViewModel:
  
  public class AViewModel
  {
      public int id { get; set; }
      public string name { get; set; }
      public string address { get; set; }
      public string phone { get; set; }
  }enter code here
  
  
  
  //My controller:
  
  [HttpGet]
      public ActionResult Add()
      {
          AViewModel d= new AViewModel ();
  
          return PartialView("_Add", d);
      }
  
      [HttpPost]
      public ActionResult Add(AViewModel a)
      {
          if (ModelState.IsValid)
          {
              ABusiness sb = new ABusiness ();
             // sb.Add(a);
  
  
              return RedirectToAction("List");
          }
  
  
          return PartialView("_Add", a);
      }
  </code></pre>