title: Get last added record ID in Entity Framework
body: <p>I'm registering a new <strong>client</strong> in my database, and when that operation finishes I want to show a detail view for that new client. The problem is I'm not finding the way to send to the <code>Details</code> action method the <code>ID</code> of the recently added client.</p>
  
  <p>I'm working on this code:</p>
  
  <pre><code>[HttpPost]
  [ValidateAntiForgeryToken]
  public ActionResult Register(ClientModel credential)
  {
      if(ModelState.IsValid)
      {
          database.Clients.Add(credential);
          database.SaveChanges();
  
          return RedirectToAction("Details", //Here is my problem, because sending credential.ID gives me an error as far as credential doesn't have an ID due it's not a database record.;
      }
      else
      {
          return View();
      }
  }
  </code></pre>
  
  <p>This is mi <code>ClientModel</code>:</p>
  
  <pre><code>[Table("Clients")]
  public class ClientModel
  {
      [Key]
      public Int16 ID { get; set; }
  
      [Required]
      public String Name { get; set; }
  
      public String Address { get; set; }
  
      [EmailAddress]
      public String EmailAddress { get; set; }
  
      [Phone]
      public String Phone { get; set; }
  
      public virtual ICollection&lt;UserModel&gt; Users { get; set; }
  }
  </code></pre>
  
  <p>Could someone bring light to my path?</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>Got an answer, which I would like to discuss:</p>
  
  <pre><code>return RedirectToAction("Details", new { ID = credential.ID });
  </code></pre>
  
  <p>This solution worked, but now the question could be, is this the <em>better solution</em>, or should I use 2 classes as commented in @Basic's answer?</p>