当前表添加新数据时为相关表创建Id MVC 5
我有一个注册后需要填写的申请表,我有一个用户和一个相关的申请表。
中创建新的 ID
我希望在用户注册并将数据添加到用户表后,在应用程序表用户表
应用表
这里我希望在数据输入时自动创建新ID添加到用户表(与所选列一样)
我用于注册的代码
public void StudentAdd(T p)
{
c.Set<T>().Add(p);
c.SaveChanges();
}
registrationRepository.StudentAdd(user);
我该如何实现? 先感谢您
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新表应用程序中的 DDL,声明 Id 列为自动增量或串行,这样做您不需要传递 id,它将自动创建。
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.