NyxSql - a journey from .Net Framework to .Net 6 - Part I

Photo by Nuril Ahsan on Unsplash

NyxSql - a journey from .Net Framework to .Net 6 - Part I

Intro

In this series, I will write about upgrading a project which was created on .Net Framework 2 to .Net Core. All steps will be included, as in pushing to a fresh github repository and every major step of the migration.

NyxSql?

At first, the name was inspired by Nyx. I decided to write this program over a decade ago, due to the lag of universal sql editors / gui tools from windows to most common databases. It was intended to be a learning project using WinForms. As I mainly used it for Oracle database it was abandoned by me when SqlDeveloper was released.

Restore of the sources and upload to github

  • Unzipped the old svn backup
  • Removed the .svn folder

Git repository

Currently I created a private git repository at GitHub. Perhaps I will make it public at some time, but due to bad experiences with projects, which had been completely cloned and used without any credits, I am keeping it private right now.

First loading of project after some years

After git was pushed and all files in place, I opened the solution with Visual Studio. The very first question which came was the 'Target framework not supported', where the upgrade to 4.8 was confirmed.

Afterwards a whole batch build and installation of odp.net.managed nuget package. Then NyxSql started without any further complains! As happy as I was about the successful start, as ugly is the GUI.. but we will have another article about that.

Upgrade assistant

For upgrading from .Net Framework or .Net Core to .Net we can use the .net upgrade assistant from Microsoft. I personally prefer to visit the github project page directly.

Now we require a command prompt (cmd) or powershell for executing the following commands.

Installation:

dotnet tool install -g --add-source https://api.nuget.org/v3/index.json --ignore-failed-sources upgrade-assistant

or if it is already installed, the update:

dotnet tool update -g --add-source https://api.nuget.org/v3/index.json --ignore-failed-sources upgrade-assistant

The upgrade itself

Open a powershell and change to the project directory, e.g.: sl d:\source\c#\NyxSql

Then we start the upgrade with: upgrade-assistant upgrade --skip-backup --non-interactive Nyx.sln

Where we use:

  • skip-backup as we are using git and need no file backup
  • non-interactive as we do not want to press 'y' over and over again for each project

Warnings / errors

After the upgrade is finished, you should analyze the output for warnings. When upgrading NyxSql we got for example following warnings:

[20:18:16 WRN] Default font in Windows Forms has been changed from Microsoft Sans Serif to Seg Segoe UI, in order to change the default font use the API - Application.SetDefaultFont(Font font). For more details see here - https://devblogs.microsoft.com/dotnet/whats-new-in-windows-forms-in-net-6-0-preview-5/#application-wide-default-font.
[20:18:41 WRN] No version of odp.net.managed found that supports ["net6.0-windows"]; leaving unchanged
[20:18:43 WRN] HighDpiMode needs to set in Main() instead of app.config or app.manifest - Application.SetHighDpiMode(HighDpiMode.<setting>). It is recommended to use SystemAware as the HighDpiMode option for better results.
[20:19:02 WRN] Manual updates needed to address: UA0013_M@SourceFile(d:\source\c#\NyxSql\Nyx\Tools\UserSettingsManager\DisplayProperty.cs[1462..1470)): Windows Forms Deprecated controls : DataGrid needs to be replaced with DataGridView. For more details see - https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls

Next to the solution Nyx it was also required to update NyxUpdate.sln in another step.

In the next article we will look at how to create plain project files and if we can run the project.