我正在使用ViewModel在页面上设置一些数据(两个下拉列表),而其他数据只是在创建新用户时提交。
例如,我有3张桌子。用户,类,ContactInfo
如果我的类和ContactInfo表都具有User表的外键“ UserId”,我该如何区分它们?
namespace School.ViewModels{
public class newStudentPage{
//student table (model)
public string Name{ get; set;}
public string LastName{ get; set;}
//contact table (model)
public int UserId{ get; set;}
public string Phone{ get; set;}
//class table (model)
public int UserId{ get; set;}
public string Class{ get; set;}
}
}
当用户提交表单时,我将创建一个新用户,返回主键,并使用该主键提交给其他两个表进行输入。
但是我需要区分这些外键。
这样做的正确方法是什么?