Prerequisites
Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.
- What is your product version? 11.0.1
- What is your product type (Angular or MVC)? MVC
- What is product framework type (.net framework or .net core)? .Net Core
I downloaded 11.0.1 Core MVC Jquery. This is a clean install, no modified code except as instructed in links.
I'm using the latest MySql connector (8.0.28), MySql.EntityFramework.Core (6.0.0).
I went through instructions detailed here: https://aspnetboilerplate.com/Pages/Documents/EF-Core-MySql-Integration :
- Changed builder.UseMySql(connectionString) in DbContextConfigurer, Configure Method.
- Deleted all migration classes and snapshot from EntityFrameworkCore project and recreated them from scratch.
As referenced in this ticket: https://support.aspnetzero.com/QA/Questions/10340/Update-Database-does-not-seed-data , the solution was to then run the migrator.
When I run the migrator I get the following error:
MySql.Data.MySqlClient.MySqlException (0x80004005): Table 'surpathv2.abpeditions' doesn't exist
From Package Manager Console, with Web.Mvc as startup project, and EntityFrameworkCore as Default project, I run add-migration Initial_Migration
It generates the error:
Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Storage.TypeMappingSourceDependencies' while attempting to activate 'MySql.EntityFrameworkCore.Storage.Internal.MySQLTypeMappingSource'.
In my database, the only table is __efmigrationshistory
My database configurater file reads as follows:
` public static class AspNetZeroDbContextConfigurer { public static void Configure(DbContextOptionsBuilder
public static void Configure(DbContextOptionsBuilder<AspNetZeroDbContext> builder, DbConnection connection)
{
//builder.UseSqlServer(connection);
builder.UseMySQL(connection);
}
}
`
I cleaned and rebuit my solution as detailed here: https://support.aspnetzero.com/QA/Questions/7462/Support-for-MySQL
No luck. Can someone please help me?
Thank you!
5 Answer(s)
-
0
Of note, I also have a 5.6 MySql instance I've tried this with. I'm getting the same error.
-
0
Update - I've also tried mySql 5.7, still doesn't work with native. Something to do with mapping.
I tried the Pomelo nuget package, and after some work - I was able to determine that the instructions for the context configurer are out of date.
Found the answer here: https://gitanswer.com/efcore-pomelo-5-0-error-a-relational-store-has-been-configured-without-specifying-either-the-dbconnection-or-connection-string-to-use-csharp-pomelo-entityframeworkcore-mysql-743662271
This worked. I updated all connection strings - and modified my configurer
using System.Data.Common; using System.Diagnostics; using Microsoft.EntityFrameworkCore; namespace YourProjectName.EntityFrameworkCore { public static class YourProjectNameDbContextConfigurer { public static void Configure(DbContextOptionsBuilder<YourProjectNameDbContext> builder, string connectionString) { builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); } public static void Configure(DbContextOptionsBuilder<YourProjectNameDbContext> builder, DbConnection connection) { builder.UseMySql(connection.ConnectionString, ServerVersion.AutoDetect(connection.ConnectionString)); } } }
I'm going to continue testing.
-
0
This also worked with MySql 8.
-
0
Hi @marble68
Thnak you for finding the solution and sharing it with us. I assume this is all resolved now, right ?
-
0
Everything seems to be testing ok - closing.