title: How to get user object and save it with model?
body: <p>I've created my incredibly simplistic model:</p>
  
  <pre><code>public class ImageModel
  {
      public int Id { get; set; }
      public string FileName { get; set; }
  }
  </code></pre>
  
  <p>And now I want to store the logged-in user with the record. Presumably, I would do this by adding another property:</p>
  
  <pre><code>public User User { get; set; }
  </code></pre>
  
  <p>Which Visual Studio is telling me is telling me is in</p>
  
  <pre><code>using System.Web.Providers.Entities;
  </code></pre>
  
  <p>Assuming that's the right <code>User</code> class that corresponds with the presently authenticated user, how do I save that with my model?</p>
  
  <p>My <code>Create</code> action looks like this:</p>
  
  <pre><code>    [HttpPost]
      public ActionResult Create(ImageModel imagemodel)
      {
          if (ModelState.IsValid)
          {
              db.ImageModels.Add(imagemodel);
              db.SaveChanges();
              return RedirectToAction("Index");
          }
  
          return View(imagemodel);
      }
  </code></pre>
  
  <p>I imagine I would want to add something like</p>
  
  <pre><code> imagemodel.User = User;
  </code></pre>
  
  <p>Just above <code>db.ImageModels.Add</code>, but those appear to be two different types. The <code>User</code> object in <code>Controller</code> appears to be an <code>IPrincipal</code> which really doesn't seem to hold much information at all. </p>
  
  <p>How do I get the rest of the user data for the authenticated user? What do I need to assign <code>imagemodel.User</code> to? Is that even the way to do it, or do I need to explicitly tell it I just want to save the User ID (I'm assuming this much it could figure out) -- and if so, how do I keep a <code>User</code> object on my model such that it points to the real User object (not just an ID), and how do I get the User ID for the currently logged in user?</p>