When creating classes via entity framework for the database tables, I got the following structure of the class.
I have two tables, app_user and expenses. there is one-to-many relationship from app_user to expenses table i.e. one app_user has many expenses.
I got the following classes:
public partial class app_user
{
public app_user()
{
this.expenses = new HashSet<expens>();
}
public int id { get; set; }
public string username { get; set; }
public string password { get; set; }
public byte user_role { get; set; }
public string is_active { get; set; }
public Nullable<System.DateTime> date_of_register { get; set; }
public virtual ICollection<expens> expenses { get; set; }
}
This class structure is used for foreign key reference in table. I want to know that,
1. why in constructor, only the foreign key reference table is defined as HASHSET?
2. what is the use of doing this, why use HASHSET?
3. why the get set property of foreign key reference table is defined as ICollection?
What is the use of doing this?
Please donot provide the definition of hashset and ICollection, I already know that. I want to know why here it is done like this? defining foreign key reference table as hashset and for property ICollection?