我正在使用像Twitter这样的Azure移动服务创建移动应用。 为了实现“跟随”功能,我创建了以下模型。
/*Model*/
//User Class
public class User : EntityData
{
public string UserName { get; set; }
public string Email { get; set; }
}
//Follow Class
public class Follow : Entity Data
{
[Key, Column(Order = 0)]
[ForeignKey("Following")]
public String FollowingId { get; set; }
public virtual User Following { get; set; }
[Key, Column(Order = 1)]
[ForeignKey("Followed")]
public String FollowedId { get; set; }
public virtual User Followed { get; set; }
}
使用上面的代码,Entity Framework创建一个表。 用户表是预期的,但Follow表不是。
预期“关注表”只有两栏如下
FollowingId FollowedId
FollowingId
和FollowedId
应该是Follow table
的复合键
用户表中的ID和外键。
如果我在上面设置,我无法使用Entity框架创建表。 任何人都可以帮我按预期创建表吗?