Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Collapse]Scheduler
   [Expand]Product Information
    Getting Started
   [Expand]Scheduler Elements and Structure
   [Collapse]Data Binding
    [Collapse]Data Sources
      Microsoft Access Database
      Microsoft SQL Server
      Business Objects
      Entity Framework
      Entity Framework Code First
      eXpress Persistent Objects (XPO)
      XML Data
      Hierarchical Resource Specifics
      Gantt View Specifics
    [Expand]Mappings
     FetchAppointments Event - Handling Large Datasets
   [Expand]Appointments
   [Expand]Views
   [Expand]Supported Formats
    Printing
   [Expand]Scheduler Reporting
   [Expand]Time Zones
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
   [Expand]Services
   [Expand]Member Tables
   [Expand]Visual Elements
   [Expand]Examples
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Entity Framework Code First

A SchedulerDataStorage can be bound to a data source created using the Entity Framework Code First approach. The following code demonstrates how to implement appointment and resource objects.

Expanded Appointments

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4107.

Expanded Resources

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4107.

Expanded DbContext

The DbContext class descendant is required to retrieve data from the database. It is implemented as follows:

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4107.

Expanded Mappings

Before binding to a data source we have to map data fields to appointment and resource properties. The code that creates the required mappings is shown below.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4107.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4107.

Expanded Database Initialization

Handle the Form.Load event to create the database, fill it with initial data and specify appointment and resource binding sources.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4107.

Not the use of the System.Data.Entity.DbExtensions.ToBindingList<T> method as the source for data binding.

Expanded Database Commit

The SaveChanges method of DbContext descendant - the SchedulerContext object - is used to commit changes to the data source. Subscribe to the SchedulerDataStorage.AppointmentsInserted, SchedulerDataStorage.AppointmentsChanged and the SchedulerDataStorage.AppointmentsDeleted events to save the SchedulerContext object.

To exclude the identity field from the fields being committed to the data source, set the AppointmentStorage.CommitIdToDataSource property to false.

Is this topic helpful?​​​​​​​