세부 테이블에있는 일부 데이터를 참조하도록 IdentityUser 파생 클래스를 갖고 싶습니다. 이렇게하기 위해 외부 세부 테이블에 대한 참조가있는 확장 된 IdentityUser를 만들고 그에 따라 해당 테이블이 만들어 지도록 IdentityDbContext를 구성했습니다.ASP.NET MVC 5 세부 테이블 읽기 ID 2
public class ApplicationUser : IdentityUser
{
public ICollection<PublishingContext> PublishingContexts { get; set; }
public ApplicationUser()
{
PublishingContexts = new List<PublishingContext>();
}
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
return userIdentity;
}
}
public class PublishingContext
{
public string UserId { get; set; }
public string Name { get; set; }
public string Uri { get; set; }
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
public virtual IDbSet<PublishingContext> PublishingContexts { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ApplicationUser>()
.HasMany(u => u.PublishingContexts).WithRequired().HasForeignKey(ul => ul.UserId);
modelBuilder.Entity<PublishingContext>()
.HasKey(c => new { c.UserId, c.Name });
}
}
문제는 PublishingContexts 테이블이 작성되는 내가 수동으로 위에 일부 데이터를 채울 경우에도 마찬가지입니다. 나는 새 테이블을 구성 할 필요가 있다고 생각에 로그온하는 동안, 나는 다시 해당 값을 읽고 관리 할 수 있다는 것입니다 어딘가에있는 시스템에 있지만, 나는 현재 붙어있다. 어떤 제안?