9

I am developing WEB API in .Net Core 2.0 with MySQL DB. I am trying to scaffolding MySQL DB. I have follow This link (MySQL Official Site) but when I fire scaffolding command I getting error both I have mention below, please do let me know if I am doing anything wrong. Command For Scaffolding(firing in Package Manager Console)

Scaffold-DbContext "server=localhost;port=3306;user=root;password=darshan7826;database=sakila" MySql.Data.EntityFrameworkCore -OutputDir sakila -f

Error on executing above command

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.

3 Answers 3

8

After digging i found that .Net Core 2.0 Mysql Connector is not working properly and after some search and RnD i found Pomelo Foundation from Stack overflow i tried it and it works.

Sign up to request clarification or add additional context in comments.

Comments

4

Taking a look at the official sourcecode for the MySQL Connector for .Net, you can see that it's not complete yet due to this:

public DatabaseModel Create(string connectionString, 
    IEnumerable<string> tables, IEnumerable<string> schemas)
{
  throw new NotImplementedException();
}

You may want to open up a bug report on the official bug tracker.

Alternatively, there does seem to be a much newer beta version that you could look at trying. https://www.nuget.org/packages/MySql.Data.EntityFrameworkCore/8.0.9-dmr

5 Comments

Lol, throw new NotImplementedException(); is pretty "standard" implementation.
@Ivan It's how I implement all my code too, you'd be amazed how quickly I can write it!
@DavidG thanks for answer, can you please let me know in file i have to add this block
It is still not implemented even with newest release of 8.0.10-rc which got released just 2 days ago :(
its odd how they have a release and this function is still not implemented
1

You should run this (from Package-Manager-Console):

Scaffold-DbContext "Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;" 
MySql.Data.EntityFrameworkCore -OutputDir Models

or use:

dotnet ef dbcontext scaffold

Note: You should be at the project in which MySql.Data.EntityFrameworkCore NuGet package has been added.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.