Skip to main content
All docs
V21.2
.NET Framework 4.5.2+

DevExpress v24.1 Update — Your Feedback Matters

Our What's New in v24.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Model First Specifics

  • 2 minutes to read

This topic lists the specifics of using the Entity Framework 6 data model created within the Entity Framework Designer (the Model First approach) in XAF. If you create your entities in code (Code First), skip this topic.

  1. In the Model First approach, a constructor with the connectionString parameter is required in the DbContext descendant when you specify the connection via the XafApplication.ConnectionString property or via the ConnectionString attribute in the configuration file (see Use the Entity Framework 6 Data Model). Add this constructor by creating a partial class that supplements your DbContext/ObjectContext descendant.

    public partial class MySolutionModelContainer : DbContext {
        public MySolutionModelContainer(string connectionString) : base(connectionString) { }
    }
    
  2. When using Model First, the metadata part of the connection string specified in the configuration file (or directly assigned to XafApplication.ConnectionString) is required. You can copy the connection string from the App.Config file generated by the Entity Framework Designer.
  3. To be able to apply attributes to entity classes, add partial classes that supplement the designer-generated code. To apply attributes to entity properties, use the approach described in the How to: Use the Entity Framework 6 Model First in XAF topic.
See Also