DEV Community

Benjamin Fadina
Benjamin Fadina

Posted on

Migrating MySQL database to SQL Server Using Radzen Blazor Studio.

Source code can be pulled from https://github.com/benjaminsqlserver/MigratingMySQLToSQLServerUsingRadzenBlazorStudio

Video Steps:-

  1. Connection is made to MySQL.
  2. Database ProductCatalogue is created with 2 tables ProductCategory and Products. A one to many relationship is also created between the 2 tables. Dummy data is also inserted into the 2 tables.
  3. A Radzen Blazor app is then created which connects to the MySQL database.
  4. The data in the two tables are then backed up as csv files via the Radzen app.
  5. A copy of the app is then pasted into the Converter folder where it is opened with Visual Studio.
  6. MySql related packages are then removed from the copy.
  7. Sql Server related packages as well as Microsoft.Entityframeworkcore.Tools packages are then added.
  8. The class BlankTriggerAddingConvention is removed from the Data folder and references to it are also removed from ConDataContext class.
  9. The appsettings.json and appsettings.development.json files are also updated to point to an instance of SQL Server.
  10. Program.cs file is also modified so that ConDataContext is initialized using SQLServer instead of Mysql. 11.Migrations for SQL SERVER are then generated using Package Manager Console.
  11. The database is then generated in SQL SERVER using update-database command 13.The converted app is then run.
  12. Data in the csv files are imported into SQL SERVER

The script used to create the initial MySQL database is as follows:-

-- Create the ProductCatalogue database
CREATE DATABASE IF NOT EXISTS ProductCatalogue;

-- Switch to the ProductCatalogue database
USE ProductCatalogue;

-- Create the ProductCategory table
CREATE TABLE IF NOT EXISTS ProductCategory (
category_id INT AUTO_INCREMENT PRIMARY KEY,
category_name VARCHAR(50) NOT NULL
);

-- Create the Product table
CREATE TABLE IF NOT EXISTS Product (
product_id INT AUTO_INCREMENT PRIMARY KEY,
product_name VARCHAR(100) NOT NULL,
price DECIMAL(10, 2) NOT NULL,
category_id INT,
FOREIGN KEY (category_id) REFERENCES ProductCategory(category_id)
);

-- Insert sample data into ProductCategory table
INSERT INTO ProductCategory (category_name) VALUES
('Electronics'),
('Clothing'),
('Books'),
('Home & Kitchen'),
('Toys');

-- Insert sample data into Product table
INSERT INTO Product (product_name, price, category_id) VALUES
('Smartphone', 599.99, 1),
('Laptop', 999.99, 1),
('T-Shirt', 19.99, 2),
('Jeans', 39.99, 2),
('Python Programming for Beginners', 29.99, 3),
('The Great Gatsby', 9.99, 3),
('Coffee Maker', 49.99, 4),
('Blender', 39.99, 4),
('LEGO Set', 59.99, 5),
('Doll', 24.99, 5),
('Tablet', 299.99, 1),
('Headphones', 79.99, 1),
('Dress', 29.99, 2),
('Sneakers', 49.99, 2),
('Data Science Handbook', 49.99, 3),
('Cookbook', 19.99, 3),
('Microwave', 99.99, 4),
('Toaster', 29.99, 4),
('Board Game', 34.99, 5),
('Action Figure', 14.99, 5);

Sentry image

Make it make sense

Only the context you need to fix your broken code with Sentry.

Start debugging →

Top comments (0)

Image of PulumiUP 2025

Let's talk about the current state of cloud and IaC, platform engineering, and security.

Dive into the stories and experiences of innovators and experts, from Startup Founders to Industry Leaders at PulumiUP 2025.

Register Now

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay