'Create Id for the related table when new data is added to the current table MVC 5
I have an application that needs to be filled in after registration, I have a User and a related Application table.
I want that after user is registered and the data was added to the User table, new Id was created in the Application table
User table
Application table
Here I want new ID to be created automatically when data is added to User table (as it is with selected column)
The code I used for registration
public void StudentAdd(T p)
{
c.Set<T>().Add(p);
c.SaveChanges();
}
registrationRepository.StudentAdd(user);
How can I implement that? Thank you in advance
Solution 1:[1]
Update the DDL in the table Application declare that Id column as Auto Increment or Serial, doing so you don't need to pass the id it will be automatically created.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Hamza Hussain |


