The Entity Data Model (EDM) is an entity relationship model that defines data in a neutral format that is not constrained by the structure of programming languages or relational databases. EDM schemas specify the details of entities and relationships and implement them as data types. The EDM maps programmable classes to data in relational storage. You can then use Object Services in the ADO.NET Entity Framework to create, read, update, and delete data as strongly typed CLR objects.
This sample demonstrates data definition using EDM schemas. The Visual Studio solution provided for this sample contains projects for both a Windows application and an ASP.NET application. The ASP.NET application uses the EntityDataSource control for data binding.
A human resources department may need to manage information about employee skills. The Human Resources Skills application helps users find information about the skills of employees or find employees with various skills.
The application specifies employee skills by using EDM entities, and it relates the skills to employees using EDM associations. Skills entities define properties for skill name and description. Another entity contains supplemental information about skills by including the URL for detailed information. An EDM association connects the supplemental information with the skill it describes. References representing people who have worked with employees are also implemented as entities. The references are accessed through an association between employee entities and reference entities.
Conceptual schema definition language (CSDL)
Store schema definition language (SSDL)
Mapping specification language (MSL)
This sample uses the following features of the Entity Framework.
Entity Data Model
Entity SQL queries
Entity object data binding
Before running this sample, make sure the following software is installed:
Visual Studio 2008 SP1 containing the .NET Framework 3.5
SQL Server 2005 or 2008 Database Engine
SQL Server Management Studio (optional)
Use the following procedure to build the sample.
In SQL Server Management Studio, navigate to the Scripts subfolder, open the HRSkillsScriptWithData.sql Transact SQL script file, and press F5 to execute the script.
This creates the HRSkills database.
Open the HRSkillsWinApp solution file in Visual Studio.
(Optional) If you created the HRSkills database in an instance of SQL Server other than the default instance on the local machine, specify the correct SQL Server instance by modifying the Data Source in the HRSkillsEntities connection string in the App.Config file of the HRSkillsWinApp project and the Web.config file of the HRSkillsOnline project.
Build the project.
Use the following procedure to run the Windows version of the sample.
Ensure that the HRSkillsWinApp project is set as the startup project for the solution.
Run the application.
Click on one of the names in the Employees data grid. The skills associated with the employee will be displayed in the Skills data grid.
Click on one of the skills in the Skills data grid.
The brief description of the skill, URLs of detailed information, and employee references are displayed in the Skills/References text area.
To display skill information, click on one of the URLs in the Skills/References text area to activate Internet Explorer or the appropriate application, depending on the type of data at the UNC address.
To add a new employee, enter first name, last name, alias, and email address of employee in the New Employee group box, and click Submit Employee.
To add a new skill, click an employee in the Employees data grid; Enter a short name and description of the skill in the text boxes provided for this purpose. Click Submit Skill.
To add skill information corresponding to a skill, click a skill in the Skills data grid. In the URL/UNC text box, add a URL or UNC path to information that describes the skill. Click Submit Info.
To add an employee reference, click an employee in the Employees data grid. In the Add Reference group, enter first name, last name, position, and email address of the reference person. Click Submit Reference.
To find skills related to employees, add skills keywords separated by a space to the text box labeled Search on Skills or Keywords. Click Enter to search. Skills related to the keywords will be displayed in the Skills data grid. Click on a skill in the Skills data grid; the employee will be selected in the Employee data grid and skill information and references displayed in the Skills/References text area.
Searches are case sensitive.
Ensure that the HRSkillsOnline project is set as the startup project for the solution.
Run the application.
When the Web browser opens, a data grid containing a list of all employees is displayed.
Click Select next to one of the names in the Employees data grid. The skills associated with the employee will be displayed in the Skills data grid, and the references will be displayed in a separate data grid.
Click Select next to one of the skills in the Skills data grid. This displays a list of links in the Additional Skills Info data grid.
To display skill information, click on one of the URLs in the Additional Skills Info data grid.
This sample runs in the development server on the local machine. To configure this application in Internet Information Services (IIS), see the IIS documentation.
Use the following procedure to remove the Human Resources Skills sample.
Delete the project directory and contents.
Drop the HR Skills database from the instance of SQL Server.