Base solution for your next web application
Open Closed

Support for MySQL #7462


User avatar
0
rickfrankel created

Hi,

So I've followed the instructions here. https://aspnetboilerplate.com/Pages/Documents/EF-Core-MySql-Integration

My setup is based on ASP.NET CORE & Angular .NET Core 2.2 v7.1.0 However I had to do a few different things.

  1. BuildWebHost section was ignored as I don't believe that is used any more in .Net Core 2.2

  2. Initially I tried to delete all the migrations as the document mentions and then run add-migration Initial_Migration

    1. The problem with this is that the initial_migration class that is added had nothing in it and basically was useless.
  3. So I put all the migrations back from the downloaded package and tried to run them.

  4. There is an error with migrationBuilder.AddColumn<string>( name: "Discriminator", table: "AbpEditions", nullable: false, defaultValue: "");

            Failed executing DbCommand (7ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
    

ALTER TABLE AbpEditions ADD Discriminator longtext NOT NULL DEFAULT ''; MySql.Data.MySqlClient.MySqlException (0x80004005): BLOB, TEXT, GEOMETRY or JSON column 'Discriminator' can't have a default value ---> MySql.Data.MySqlClient.MySqlException (0x80004005): BLOB, TEXT, GEOMETRY or JSON column 'Discriminator' can't have a default value

Looking into it they appear to be correct. Default values are not supported for text types.

Commenting out the default to continue and we move onto this file. 5) 20170913133916_Added_SharedMessageId_To_ChatMessage 1) The type specified in there is an MSSQL type only. 2) migrationBuilder.AddColumn<string>( name: "SharedMessageId", table: "AppChatMessages", type: "nvarchar(max)", nullable: true);

            Failed executing DbCommand (3ms) [Parameters=[], CommandType='Text', CommandTimeout='30']

ALTER TABLE AppChatMessages ADD SharedMessageId nvarchar(max) NULL; MySql.Data.MySqlClient.MySqlException (0x80004005): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'max) NULL' at line 1 --->

And there is more if I continue. So the question is. Does ASP.Net Zero really support MySQL. Based on the migration scripts I'm seeing that are on top of Boilerplate. I'm guessing the answer is actually No and not the yes I was previously told.

Thanks Rick


1 Answer(s)
  • User Avatar
    0
    rickfrankel created

    I have solved my own problem I think here. The issue is related to number 2 above.

    After you delete all the migration files you need to clean your solution, rebuild it and then run add-migrations. This then added the correct initial migration file and away we go.