asp.net mvc - Tracking a user by GUID or by an integer in identity 2 -


as of identity 2 have switched id integer value (ex. 1,2,3,4,...) id nvarchar value stores id long string like

a234vt-23sdlj23klj-34jkh34jh34-23jk4jh2 

if i'm creating object have single owner belonging person logged in, need attach user id it, should use new id identity 2 or should try , create other value integer , put aspnetusers table? matter, i'm doing fetching gift object owner(userid) , displaying/modifying gift objects on form.

here example of product object

public class gift {     public int id { get; set; }     public string name { get; set; }     public icollection<category> categories { get; set; }     public int rating { get; set; }     public giftstatus status { get; set; }     public string userid {get; set; //where userid id of user owns object, should 3kj23jh3-h3hk1jh2-khj2h34l1b-n22g35l  ???  } 

there no problem using guid userid reference user, if that's you're concerned about. unless have specific reason not wanting use guid userid, suggest use default behavior in order simplify implementation. having 2 separate ids keep track of user sounds needlessly complicated, wouldn't recommend path.

if have reason requiring int primary key instead of guid, might take @ this: http://blogs.msdn.com/b/webdev/archive/2014/03/20/test-announcing-rtm-of-asp-net-identity-2-0-0.aspx (scroll down "make type of primary key extensible users , roles" section). page has link example project shows how use int pk. mentions extension can used migrate applications use int pks new identity 2.0.

here's article may helpful: http://www.codeproject.com/articles/777733/asp-net-identity-change-primary-key


Comments