ASP.NET Core 3.1 Identity tables in MySQL

To have identity tables in MySQL install Pomelo package, set the connection string and DBContext in Startup.cs like this:

services.AddDbContext(options => options.UseMySql(Configuration.GetConnectionString("MySqlConnection"));

Open NuGet > Package Manager Console
Run: EntityFrameworkCore\Update-Database -Verbose
Run: update-database

Continue Reading

Entity Framework in .NET and MySQL tinymce(1) problem

You know at tinymce(1) field in MySQL database will be converted to boolean type in C#. Sometimes you don’t want this because you just want to read the integer value from MySQL in this field (it can be any from 0-255 if unsigned or -127-127 if signed) – one byte.

In order to do so you need to do two things:

  1. Add TreatTinyAsBoolean=false to your connection string
  2. Edit the database edmx file and in SSDL content section change bool to tinyint, and in CSDL content section change Boolean into SByte.

Be careful if you update edmx file because changes you have made will be lost. This is the bad thing about this, but it is working solution.

Continue Reading