Why Express App (XAF)?

I have been using Express APP (XAF) from Developer Express for applications for as long as I can remember; mostly to play around with. The reason? I have been so fascinated by the development process involved (building the business objects first) and the rapid development possibilities this framework has. On a few occasions, I have even delivered solutions to customers in this framework. In this case, I was looking at it as a possible solution to reach the requirements for a customer while keeping the price down using rapid development. I wanted to host an XAF Web Application in an Azure Web App, due to it’s fast and smooth integrations with Azure DevOps and the possibility to get something up and running fast without disturbing the in-house operations people.

What I Did:

I deployed a .NET 4.7.2 Express App framework (XAF) Web Application to the Azure Web App through an Azure DevOps build-and-release pipeline. First, I tried out using an Azure SQL database – but the performance of the app was not satisfactory. Then, I thought that the performance might be low because of the communication over the network to the Azure SQL database, so I got the idea to use the “MySQL In-app” database instead, which is running on the same physical unit as the app.

Process:

I spent some time getting this to work, so I thought I might share the process that I ended up following to get this up-and-running. Unfortunately, the performance of my app did not improve much. A two-second load time for editing a DetailView is not satisfactory in my world. I could upgrade the Web App plan, but then I would end up in an unreasonable payment each month with the S1 plan. I tried upgrading to p1V2 but the performance still wasn’t satisfactory and the price was escalating. So, now we might move this app in-house or I could spend a lot of time performance-optimizing my app. But then I would lose the benefits of the rapid app development from using XAF. Either way, it was fun trying to get it to run. EDIT: with fine advice from Dennis from DevExpress we found out that the office component was the sinner, concerning performance and therefore this solution is actually being used by the customer.

Prerequisites:

  • XAF Web App Project to deploy.
  • Build-and-deployment pipeline to deploy to a Web App Service in Azure Portal.

Process:

  • Activate the “MySQL In-app” opportunity in the Azure Portal Web App. Go to Settings > MySQL In-app and activate the feature by clicking the “On” button.
  • Make changes to your XAF Web Application so that it uses the MySQL In-app opportunity instead of the default Missal. Comment the current config parameters in the web.config file.
    • Get the environment variable code in your web application projects Global.asax.cs file add the following code:
            WebApplication.Instance.SwitchToNewStyle();
          
            if (ConfigurationManager.ConnectionStrings["ConnectionString"] != null)
            {
                WebApplication.Instance.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            }
            else
            {
                string connection = Environment.GetEnvironmentVariable("MYSQLCONNSTR_localdb");
                string dbhost = Regex.Match(connection, @"Data Source=(.+?);").Groups[1].Value;
                string server = dbhost.Split(':')[0].ToString();
                string port = dbhost.Split(':')[1].ToString();
                string dbname = Regex.Match(connection, @"Database=(.+?);").Groups[1].Value;
                string dbusername = Regex.Match(connection, @"User Id=(.+?);").Groups[1].Value;
                string dbpassword = Regex.Match(connection, @"Password=(.+?)$").Groups[1].Value;

                WebApplication.Instance.ConnectionString = MySqlConnectionProvider.GetConnectionString(server, Convert.ToInt32(port), dbusername, dbpassword, dbname);
            }

  • Uncomment the update database stuff in the application module in the WebApplication.cs file in the web project for now.
//        if(System.Diagnostics.Debugger.IsAttached) {
    //            e.Updater.Update();
    //            e.Handled = true;
    //        }
    //        else {
				//string message = "The application cannot connect to the specified database, " +
				//	"because the database doesn't exist, its version is older " +
				//	"than that of the application or its schema does not match " +
				//	"the ORM data model structure. To avoid this error, use one " +
				//	"of the solutions from the https://www.devexpress.com/kb=T367835 KB Article.";

    //            if(e.CompatibilityError != null && e.CompatibilityError.Exception != null) {
    //                message += "\r\n\r\nInner exception: " + e.CompatibilityError.Exception.Message;
    //            }
    //            throw new InvalidOperationException(message);
    //        }
  • Add the MySQL Connection MySQL.data to your build. I got it working with version MySQL.Data 6.9.9 which is recommended from DevExpress.

Limitations:

I know that it is not recommended to use the MySQL In-app Database for production, but the data in the app is all of the data which is currently synchronized from another database; and if the database somehow breaks all the data can be seeded again within 15 minutes. So, it’s not critical data. When this will – eventually – be a stand alone application, the database type can be changed in a gitty without big costs, taking no more than a couple of hours.

Last modified: December 10, 2020

Author

Comments

Write a Reply or Comment

Your email address will not be published.