[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [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]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
   [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
     FetchAppointments Event - Handling Large Datasets
   [Expand]Import and Export
   [Expand]Time Zones
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
   [Expand]Member Tables
   [Expand]Visual Elements
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst 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]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

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

Expanded Resources

Expanded DbContext

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

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.

Expanded Database Initialization

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

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?​​​​​​​