MySQL Forums
Forum List  »  MySQL for Visual Studio

.Net Core Entity Framework scaffolding does not work
Posted by: Stephen Miller
Date: February 24, 2020 05:08PM

I have installed MySQL Community v8.0.19 and MySQL for Visual Studio v 1.2.9 and have been trying to integrate some web services I am writing using Entity Framework Core. The webservices project is using .Net Core 3.1. I have followed line by line the instructions in 8.2.2 Scaffolding an Existing Database in EF Core on how to scaffold the existing database into the project. It simply does not work. I get the following stack dump:

scaffold-dbcontext "server=localhost;user id=root;database=accountmanagement;" MySql.Data.EntityFrameworkCore -outputdir Models2 -tables t1,t2,...tn -schema accountmanagement
Build started...
Build succeeded.
System.TypeLoadException: Method 'Create' in type 'MySql.Data.EntityFrameworkCore.Scaffolding.Internal.MySQLDatabaseModelFactory' from assembly 'MySql.Data.EntityFrameworkCore, Version=8.0.19.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' does not have an implementation.
at MySql.Data.EntityFrameworkCore.Design.Internal.MySQLDesignTimeServices.ConfigureDesignTimeServices(IServiceCollection serviceCollection)
at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.ConfigureDesignTimeServices(Type designTimeServicesType, IServiceCollection services)
at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.ConfigureProviderServices(String provider, IServiceCollection services, Boolean throwOnError)
at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.Build(String provider)
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, 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 outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_0.<.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)
Method 'Create' in type 'MySql.Data.EntityFrameworkCore.Scaffolding.Internal.MySQLDatabaseModelFactory' from assembly 'MySql.Data.EntityFrameworkCore, Version=8.0.19.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' does not have an implementation.

I used Resharper to look into the MySQL.Data.EntityFrameworkCore dll and do find a Create method so I am at a loss. I have tried:

1) scaffold-dbcontext "server=localhost;user id=root;database=accountmanagement;" MySql.Data.EntityFrameworkCore -outputdir Models -tables t1,t2,...tn -schema accountmanagement
2) scaffold-dbcontext "server=localhost;user id=root;database=accountmanagement;" MySql.Data.EntityFrameworkCore -outputdir Models -tables t1,t2,...tn
3) scaffold-dbcontext "server=localhost;user id=root;database=accountmanagement;" MySql.Data.EntityFrameworkCore -outputdir Models -f

and they all abort with the same error message. Your documentation is obviously not correct or there is a bug. Either way, I am not getting to success at all.

Please advise as to how to actually do this!

Regards,
Steve Miller

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.