我有这样的事情:
public class something {
[Key]
public int Id {get;set;}
public string Name {get;set;}
}
public class secondsomething {
[Key]
public int Id {get;set;}
[ForeignKey("Sth") {get;set;}
public int sthId{get;set;}
public something Sth{get;set;}
}
我想要这个:
public class something {
[Key]
public int Id {get;set;} //keep this as primary key
public string Name {get;set;} //maybe somehow mark this as a secondary key
}
public class secondsomething {
[Key]
public int Id {get;set;}
[ForeignKey("Sth") {get;set;}
public string sthName{get;set;} //don't want the id here, but it's name
public something Sth{get;set;}
}
有没有办法实现这一目标?