I have a model
public User
{
public long Id {get;set;}
public string UniqueUserId{get;set;}
public string Company {get;set;}
public string City {get;set;}
}
here Id is primary key with auto increment, Company and City which are the values entered by user. UniqueUserId is pattern value. its 16 digit value. It contains 1st 4 characters of Company, 4 characters from city and rest of digits are taken from the Id(suppose Id is 1 I will insert other digits as 0 using loop).
what I am actually doing now is that =>
- Read data from user
- Insert the data into context and then save changes
- Get the successfully inserted data from context
- Generate the UniqueUserId
- Update the entity and save the changes with context
I know there better methods to do this. But I don't get it. so any improved and better solution?