In my system (C#, MVC, MSSQL,Entity framework) I have a Dictionary for Employee Leave Entitlement in Employee class.
public Dictionary<string, EmployeeLeaveEntitlement> LeaveEntitlementDetails { get; internal set; }
EmployeeLeaveEntitlement class as follows,
/// <summary>
/// Gets or sets the type of the leave.
/// </summary>
/// <value>The type of the leave.</value>
public string LeaveType { get; set; }
/// <summary>
/// Gets or sets the entitlement.
/// </summary>
/// <value>The entitlement.</value>
public double Entitlement { get; set; }
/// <summary>
/// Gets or sets the availed count.
/// </summary>
/// <value>The availed count.</value>
public double AvailedCount { get; set; }
What i need is, connect a database to the system,
I already Created context for employee,
public DbSet<Employee> Employees { get; set; }
when I run the system it will create database but there are no table or column for the Leave Entitlement..Is there a way to add data to database from a Dictionary?
Help me
Thanks in Advanced.
Dictionary types can not be mapped with Entity Framework.
I do not know what you represent by the key of the dictionary, but you can create a new intermediate entity with keys of
Employee,EmployeeLeaveEntitlementand dictionary key and map this as a collection in yourEmployeeclass