Description:
PM> Scaffold-DbContext "server=*******;port=3306;user=******;password=******;database=*****" MySql.Data.EntityFrameworkCore -OutputDir ***** -f
System.NotImplementedException: The method or operation is not implemented.
at MySql.Data.EntityFrameworkCore.Scaffolding.Internal.MySQLDatabaseModelFactory.Create(String connectionString, IEnumerable`1 tables, IEnumerable`1 schemas)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.Create(String connectionString, IEnumerable`1 tables, IEnumerable`1 schemas, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ModelScaffolder.Generate(String connectionString, IEnumerable`1 tables, IEnumerable`1 schemas, String projectPath, String outputPath, String rootNamespace, String contextName, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_1.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
The method or operation is not implemented.
This is what I'm presented with when attempting to scaffold an existing database with EFCore and MySQL's EFCore libraries. This happens on both the latest stable (6.10.6) and latest pre-release (8.0.10-rc) versions.
Source code contains these two methods that don't have implementations:-
public DatabaseModel Create(string connectionString, IEnumerable<string> tables, IEnumerable<string> schemas)
{
throw new NotImplementedException();
}
public DatabaseModel Create(DbConnection connection, IEnumerable<string> tables, IEnumerable<string> schemas)
{
throw new NotImplementedException();
}
How to repeat:
(Assuming setup instructions have been followed from https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework-core.html. Visual Studio 2017 Community Edition was used)
1. Create new .Net Core Console App in Visual Studio
2. Install relevant packages from NuGet
3. Attempt to scaffold database in Package Manager Console using 'Scaffold-DbContext' command
Steps to verify source code is missing from installed package:
1. Install NuGet Package
2. Using JetBrains dotPeek program OR Resharper's Assembly Explorer, open package/assembly
3. Navigate to MySql.Data.EntityFrameworkCore.Scaffolding.Internal namespace
4. Navigate to MySQLDatabaseModelFactory class
5. Scroll to bottom of class to see the two functions causing the issue
Suggested fix:
Implement the functions required to scaffold the database