Skip to main content
All docs
V25.1
  • .NET Framework 4.6.2+

    XAF0033: EF Core business class properties should not be overridden

    • 2 minutes to read

    Severity: Warning

    XAF and EF Core do not support the following business object’s properties:

    • Declared with the new keyword
    • Overridden properties
    • Abstract properties

    For more information about these requirements, see the following article: Can I override properties of business objects?.

    This diagnostic works only for EF Core classes derived from the DevExpress.Persistent.BaseImpl.EF.BaseObject class. This diagnostic does not check static properties.

    Examples

    Invalid Code

    using DevExpress.Persistent.Base;
    using DevExpress.Persistent.BaseImpl.EF;
    
    namespace MySolution.Module.BusinessObjects {
        public class TestClass : BaseObject {
            private int testProperty1; 
            // The property must not override a property from a base class
            public override int TestProperty1 { // Warning: XAF0033
                get { return testProperty1 + 1; }
                set { SetPropertyValue(nameof(TestProperty1), ref testProperty1, value); }
            }
    
            private int testProperty2; 
            // The property must not be declared with the `new` keyword
            public new int TestProperty2 { // Warning: XAF0033
                get { return testProperty2 + 1; }
                set { SetPropertyValue(nameof(TestProperty2), ref testProperty2, value); }
            }
        }
    }
    

    Valid Code

    using DevExpress.Persistent.Base;
    using DevExpress.Persistent.BaseImpl.EF;
    
    namespace MySolution.Module.BusinessObjects {
        public class TestClass : BaseObject {
    
            private int testProperty;
            // The property that meets the requirements
            public int TestProperty { 
                get { return testProperty; }
                set { SetPropertyValue(nameof(TestProperty), ref testProperty, value); }
            }
        }
    }
    

    How to Fix

    Check the business object’s property declaration and ensure the property is declared without the following modifiers:

    • abstract
    • override
    • new