当我们启动一个正常的MVC项目时,它带有Identity.I有一些模型,如Post.cs和Comment.cs
帖子和评论之间的一对多关系
public class Post
{
public int PostId { get; set; }
public string Baslik { get; set; }
public string Icerik { get; set; }
public virtual ICollection<Comment> Comments { get; set; }
}
public class Comment
{
public int CommentId { get; set; }
public string Icerik { get; set; }
public int PostId {get;set;}
public virtual Post Post { get; set; }
}
IdentityModel.cs
我们这里什么也没有,但是当我在IdentityUser上点击ctrl
public class ApplicationUser : IdentityUser
{
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection")
{
}
}
public class IdentityUser : IUser
{
public IdentityUser();
public IdentityUser(string userName);
public virtual ICollection<IdentityUserClaim> Claims { get; }
public virtual string Id { get; set; }
public virtual ICollection<IdentityUserLogin> Logins { get; }
public virtual string PasswordHash { get; set; }
public virtual ICollection<IdentityUserRole> Roles { get; }
public virtual string SecurityStamp { get; set; }
public virtual string UserName { get; set; }
}
对我来说仍然很奇怪,我在IUser上用ctrl点击了
// Summary:
// Minimal interface for a user with a string user key
public interface IUser
{
// Summary:
// Unique key for the user
//
// Returns:
// The unique key for the user
string Id { get; }
string UserName { get; set; }
}
我错过了什么?我只想在Post
和Comment
模型之间建立关系用户评论和用户帖子。