Human Resources Skills WinApp (EDM Sample Application)

.NET Framework 3.5

Human Resources Skills is a Windows Forms application that enables you to track the skills and personal references that an employee has obtained. A single form enables you to create and view employees and their skills and references. For a given employee, you can add a new skill or reference. This sample shows how to use the Entity Framework to access and change entity data.

Downloading and Running the Sample

The Human Resources Skills sample is available on the ADO.NET Entity Framework Documentation Samples resource page in MSDN Code Gallery. Requirements and instructions for building and running the sample are provided in the readme.htm file in the download package.


The published solution also contains a project for the Human Resources ASP.NET Web Site (EDM Sample Application). This ASP.NET application is a query-only version of the Human Resources Skills application.

Sample Scenario

Managing information about employee skills is an interesting scenario for an application that is built on the Entity Data Model (EDM). This application makes it easy for users to determine the skills of any employee included in the system or to find an employee with identifiable skills.

Information on employee skills is specified by using EDM entities and associations. Skills entities identify employee skills by name and a brief description. Supplemental information about skills is provided by an entity that includes a URL locating the information. An association connects the supplemental information with the skill it describes. References by people who have worked with employees in the system are implemented as entities made available through associations with the entities that represent the employees they reference.

Data Design

This sample has a simplified design compared to a real-world application. When you design your own application, use the details that you discover to create entities, properties of entities, and associations in the application domain. You can then formally specify these entities, properties, and associations in conceptual schema definition language (CSDL).

In this sample, there are four abstract entities and three relationships among them. These entities and associations define the data that is used to identify and describe employees and their skills.

The following entity types are declared and defined in the schema that implements data in this application.

  • Employees

  • References

  • Skills

  • SkillInfo

The following associations define the relationships between the entity types.

  • Skill_Employee Association

  • Reference_Employee Association

  • SkillInfo_Skill Association

Entity Framework Features

This sample demonstrates the following features of the Entity Framework.

Entity Data Model (EDM)

The sample uses a data model that is based on the HRSkills database. The model was generated by using the Entity Data Model tools and is maintained in the HRSkills.edmx file in the Visual Studio project. To review the HRSkills data model, open this model file in the Entity Data Model Designer in Visual Studio and open the Model Browser and Mapping Details windows.

Data binding

Data sources are defined for Employees and Skills entity types that are bound to DataGridView controls. These data sources enable data bindings to be defined in Visual Studio. For more information, see How to: Add an Object as a Project Data Source (Entity Framework).

Query builder methods

Query builder methods are methods of ObjectQuery that can be used to sequentially construct query commands that are to the same as Entity SQL. For more information, see Query Builder Methods (Entity Framework).

Business logic

The Entity Framework does not support server-generated GUID values. To ensure that new GUID values are always created for new objects, the sample handles the SavingChanges event to generate a new GUID value for any object in the Added state. For more information, see Working with Entity Keys (Entity Framework).

Long-running ObjectContext

Because the Windows Forms contain controls that are bound to data in the ObjectContext, the context must be persisted throughout the duration of the forms. This ObjectContext instance is passed to the FormAddSalesOrderDetail form. Object Services automatically opens and closes the connection as needed. When the form is closed, the context is explicitly disposed of. For more information, see Managing Resources in Object Services (Entity Framework).

See Also

Community Additions