Breaking Change T1215959
Visible to All Users

Core - IXafEntityObject.OnSaving() method is now called on the server side when EF Core with Middle Tier Security is used

What Changed

If an application uses EF Core and Middle Tier Security, the IXafEntityObject.OnSaving() method is now called only on the Middle Tier server side when the application is saving an object.

Reasons for Change

When using Middle Tier Security, some security-sensitive properties should only be changed on the server side. You can find an example of such a usage scenario here: How to implement the CreatedBy, CreatedOn and UpdatedBy, UpdatedOn properties in a business class. In order to support this and other similar usage scenarios, the Middle Tier Security Server calls the IXafEntityObject.OnSaving() method before saving the object to the database.

Impact on Existing Apps

The change affects XAF and non-XAF applications that use EF Core and Middle Tier Security mode. If any business logic is implemented in the IXafEntityObject.OnSaving() method, this logic will now be executed on the Middle Tier Security server side.

How to Revert to Previous Behavior

  1. Enable client-side calling of the IXafEntityObject.OnSaving() method in a Windows Forms application. Add the following option to Application Builder:

File: MySolution.Win\Startup.cs

C#
public class ApplicationBuilder : IDesignTimeApplicationFactory { public static WinApplication BuildApplication(string connectionString) { // ... builder.Security .UseMiddleTierMode(options => { options.EnableClientSideXafEntityObjectOnSavingCall = true; // ... }) // ... } }
  1. In the IXafEntityObject.OnSaving() method in Business Object classes, implement a check for whether the code is executed on the Middle Tier Server side as follows.
C#
using DevExpress.ExpressApp.EFCore; // ... public class BusinessObject : BaseObject { // ... public override void OnSaving() { base.OnSaving(); if (!SecuredPropertySetter.IsRunningOnMiddleTierServer(this)) { // ... } } }

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.