sunn789
یک شنبه 05 مرداد 1393, 19:49 عصر
سلام
دوستان بیش از چند ساعته درگیر ایجاد یک لیست باز شو در زمان ثبت نام هستم یعنی زمانی کاربر ثبت نام میکند یه لیت یاز شو هم باشد تا بتوان از آن انتخاب کرد
این هم کد دو تا مودل
// You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
public class User : IdentityUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string FatherName { get; set; }
public string NationalCode { get; set; }
public string IdentityCode { get; set; }
public string Phone { get; set; }
public string Mobile { get; set; }
public string Description { get; set; }
public int StockHolderId { get; set; }
public virtual StockHolder StockHolders { get; set; }
public virtual ICollection<CheckOutMember> CheckOutMembers { get; set; }
...
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<StockHolder>()
.HasRequired<User>(profile => profile.ApplicationUsers);
base.OnModelCreating(modelBuilder);
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
}
وکد مودل دوم
public class StockHolder
{
public int ID { get; set; }
[Required]
[Display(Name = "نام")]
[MaxLength(50)]
public string Name { get; set; }
[Required]
[Display(Name = "توضیحات")]
[MaxLength(50)]
public string Description { get; set; }
public virtual User ApplicationUsers { get; set; }
}
به نظر شما مشکل مجاست؟
دوستان بیش از چند ساعته درگیر ایجاد یک لیست باز شو در زمان ثبت نام هستم یعنی زمانی کاربر ثبت نام میکند یه لیت یاز شو هم باشد تا بتوان از آن انتخاب کرد
این هم کد دو تا مودل
// You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
public class User : IdentityUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string FatherName { get; set; }
public string NationalCode { get; set; }
public string IdentityCode { get; set; }
public string Phone { get; set; }
public string Mobile { get; set; }
public string Description { get; set; }
public int StockHolderId { get; set; }
public virtual StockHolder StockHolders { get; set; }
public virtual ICollection<CheckOutMember> CheckOutMembers { get; set; }
...
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<StockHolder>()
.HasRequired<User>(profile => profile.ApplicationUsers);
base.OnModelCreating(modelBuilder);
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
}
وکد مودل دوم
public class StockHolder
{
public int ID { get; set; }
[Required]
[Display(Name = "نام")]
[MaxLength(50)]
public string Name { get; set; }
[Required]
[Display(Name = "توضیحات")]
[MaxLength(50)]
public string Description { get; set; }
public virtual User ApplicationUsers { get; set; }
}
به نظر شما مشکل مجاست؟