Reputation: 1
I use ASP.NET Identity
in an MVC
project and I need to create entity relation between ASP.NET Identity AspNetUsers
entity and my custom tables. As it is known, AspNetUsers
table uses string for Id field and there is GUID values in this Id field. However, I am not sure about the issues below:
1) What data type should I use in my custom classes in order to create PK/FK
relation? string or GUID?
2) How can I make this custom Id field to be generated automatically for every new record? Is it also possible to make it sequential
so that the records can be sorted?
Upvotes: 0
Views: 600
Reputation: 9927
1-You should use string
. (see this)
If you open the edmx
you see that Id
(GUID) in AspNetUser
is string
.
2-You can use constructor in model and generate GUID filed in it like this:
public partial class Student
{
public Student()
{
Id = System.Guid.NewGuid().ToString();
}
//Other fileds
}
3- for Sequential Guid Generator see this.I suggest UuidCreateSequential
.
Upvotes: 1