Hi,
How do i can use ASP.NET MVC Identity as foreign key ?
I have users using ASP.NET MVC Identity (User individual account),
and they can have many Documents (another model).
so, my users can add documents file.
public class ApplicationUser : IdentityUser
{
public string Email { get; set; }
public string Country { get; set; }
public string State { get; set; }
public string City { get; set; }
public virtual ICollection<Document> Documents { get; set; }
}
public enum DocumentCategory
{
Photo = 0,
Music = 1,
Video = 2,
Other = 3
}
public class Document
{
public int Id { get; set; }
public string Name { get; set; }
public string Path { get; set; }
public DocumentCategory Category { get; set; }
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include="Id,Name,Path,Category")] Document document)
{
if (ModelState.IsValid)
{
db.Documents.Add(document);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(document);
}
That's correct? if yes, how i change my DocumentController, Create Action to do correct insert?
someone can help me? Thanks