環境
VisualStudio2019
.NET CORE 3.1
MySQL8.0
手順
Blazorアプリの作成
SQLServer用のMigrationファイルを削除します。
appsettings.jsonをMySQL用に書き換え
appsettings.json
{
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;user id=xxxx;password=xxxx;database=xxxx"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
NuGetパッケージの管理から「Pomelo.EntityFrameworkCore.MySql」をインストールします。
###「"UseSqlServer"の定義が含まれておらず...」のエラーが発生するので、UseSqlServerを「UseMySql」に変更
[変更前]
パッケージマネージャーコンソールで下記コマンドを入力
add-migration 'identity'
続けて下記コマンドを入力
Update-Database
アプリを起動してユーザー登録を行う
データが登録されていれば完了
参考記事