Bug Report T711818
Visible to All Users

Core - Design-time Model Editor does not take Entity Framework class metadata into account

created 6 years ago (modified 6 years ago)

Known issues:

  1. Layout settings do not affect large properties decorated with the MaxLength attribute.
  2. Cannot set a column sorting or grouping in the Columns designer in Server and InstantFeedback modes.
  3. Design-time Criteria Builder stores enumeration values in an inappropriate format.
  4. The PropertyName selector is empty in the standalone Model Editor.

For more information, refer to the following tickets:
Web LookupListView ignores column configuration from model
EF - Display data model properties in the design-time Model Editor
Detailview layout set in model not match with the UI
Issue with ASP.NET EF XAF application with text fields more than 255 chars
Core.EF - Large properties decorated with the MaxLength attribute cannot be hidden in the Model Editor

Answers approved by DevExpress Support

created 6 years ago (modified 6 years ago)

We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

Additional information:

In XAF applications based on Entity Framework, the Types Info Subsystem needs an instance of the ObjectContext or DbContext class to retrieve complete information about business classes and their properties. Since there is no common way to create a context instance at design time, the Application Model shown in the design-time Model Editor may differ from the model generated at runtime.

To address this issue, we've provided the capability to specify the design-time context as follows:

  1. Create an ObjectContextTypesInfoInitializerBase or DbContextTypesInfoInitializerBase descendant and override the ObjectContextTypesInfoInitializerBase.CreateObjectContext or DbContextTypesInfoInitializerBase.CreateDbContext method, respectively.
  2. Decorate your context class with the TypesInfoInitializer attribute and specify the type of your Types Info Initializer class.
  3. Add a default constructor to your DbContext class descendant.
    The following code demonstrates how this approach is used in the EF Demo Code First and Model First projects.
    Code First:
C#
using System.Data.Entity.Infrastructure; using DevExpress.ExpressApp.Design; using DevExpress.ExpressApp.EF.DesignTime; namespace EFDemo.Module.Data { public class EFDemoDbContextInitializer : DbContextTypesInfoInitializerBase { protected override DbContext CreateDbContext() { DbContextInfo contextInfo = new DbContextInfo(typeof(EFDemoDbContext), new DbProviderInfo(providerInvariantName: "System.Data.SqlClient", providerManifestToken: "2008")); return contextInfo.CreateInstance(); } } [TypesInfoInitializer(typeof(EFDemoDbContextInitializer))] public class EFDemoDbContext : DbContext { public EFDemoDbContext(String connectionString) : base(connectionString) { } public EFDemoDbContext() { } ... } }

Model First:

C#
using DevExpress.ExpressApp.Design; using DevExpress.ExpressApp.EF.DesignTime; using System.Data.Entity.Core.EntityClient; namespace EFDemo.Module.Data { public class EFDemoObjectContextInitializer : ObjectContextTypesInfoInitializerBase { protected override ObjectContext CreateObjectContext() { EntityConnectionStringBuilder efConnectionStringBuilder = new EntityConnectionStringBuilder(); efConnectionStringBuilder.Metadata = "res://*/Data.EFDemoModel.csdl|res://*/Data.EFDemoModel.ssdl|res://*/Data.EFDemoModel.msl"; efConnectionStringBuilder.Provider = "System.Data.SqlClient"; return new EFDemoObjectContext(efConnectionStringBuilder.ConnectionString); } } [TypesInfoInitializer(typeof(EFDemoObjectContextInitializer))] public partial class EFDemoObjectContext { public EFDemoObjectContext(string connectionString) : base(connectionString, "EFDemoObjectContext") { this.ContextOptions.LazyLoadingEnabled = true; } ... } }

Note that after these changes the Model Editor might take longer to open because the full type metadata is generated.

    Comments (2)
    S S
    Sanjay Akut - EIG 5 years ago

      I received this error again (Filter Builder dialog not able to open) when upgrading to 19.2.3.  I reverted back to 19.1.5 and it works fine.

      Andrey K (DevExpress Support) 5 years ago

        Hello,

        We reproduced the error in v19.1.5. We will research it in a separate thread that I've created on your behalf:T831639: Core - Design-time Model Editor does not take Entity Framework class metadata into account with UseDefaultTypeDiscoveryService = False. Please bear with us.

        Thanks,
        Andrey

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.