Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"dotnet ef dbcontext scaffold" command: Which provider name? #14

Open
Schaussi opened this issue Sep 5, 2016 · 6 comments
Open

"dotnet ef dbcontext scaffold" command: Which provider name? #14

Schaussi opened this issue Sep 5, 2016 · 6 comments

Comments

@Schaussi
Copy link

Schaussi commented Sep 5, 2016

I would like to create my DbContext from an existing MySQL database. MS describes this for SQL Server here.
I tried some provider names like MySQL.Data.Entity.MySQLDatabaseProvider, MySQL.Data.Entity, SapientGuardian.EntityFrameworkCore. ..., but none of them worked.
Error "Could not find provider".
Please give me a hint for this issue.
Thank you

@SapientGuardian
Copy link
Owner

I don't believe reverse engineering a DB is supported by this library at this time. Giving the assembly name of SapientGuardian.EntityFrameworkCore.MySql resulted in

System.AggregateException: One or more errors occurred. (Unable to find expected assembly attribute named DesignTimeProviderServicesAttribute in provider assembly SapientGuardian.EntityFrameworkCore.MySql. This attribute is required to identify the class which acts as the design-time service provider factory.) ---> System.InvalidOperationException: Unable to find expected assembly attribute named DesignTimeProviderServicesAttribute in provider assembly SapientGuardian.EntityFrameworkCore.MySql. This attribute is required to identify the class which acts as the design-time service provider factory.
   at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.GetProviderDesignTimeServices(String provider, Boolean throwOnError)
   at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.Build(String provider)
   at Microsoft.EntityFrameworkCore.Design.DatabaseOperations.ReverseEngineerAsync(String provider, String connectionString, String outputDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Design.Internal.OperationExecutor.ReverseEngineerAsync(String provider, String connectionString, String outputDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Tools.Cli.DbContextScaffoldCommand.<ExecuteAsync>d__1.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at Microsoft.EntityFrameworkCore.Tools.Cli.Program.Main(String[] args)
---> (Inner Exception #0) System.InvalidOperationException: Unable to find expected assembly attribute named DesignTimeProviderServicesAttribute in provider assembly SapientGuardian.EntityFrameworkCore.MySql. This attribute is required to identify the class which acts as the design-time service provider factory.
   at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.GetProviderDesignTimeServices(String provider, Boolean throwOnError)
   at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.Build(String provider)
   at Microsoft.EntityFrameworkCore.Design.DatabaseOperations.ReverseEngineerAsync(String provider, String connectionString, String outputDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Design.Internal.OperationExecutor.ReverseEngineerAsync(String provider, String connectionString, String outputDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Tools.Cli.DbContextScaffoldCommand.<ExecuteAsync>d__1.MoveNext()<---
One or more errors occurred. (Unable to find expected assembly attribute named DesignTimeProviderServicesAttribute in provider assembly SapientGuardian.EntityFrameworkCore.MySql. This attribute is required to identify the class which acts as the design-time service provider factory.)

And sure enough, we don't have DesignTimeProviderServicesAttribute anywhere in the source tree that I could find. You might try your luck with the recently-released official mysql ef core library, https://www.nuget.org/packages/MySql.Data.EntityFrameworkCore/

@Schaussi
Copy link
Author

Schaussi commented Sep 5, 2016

Unfortunately, it is not working with the official packages yet (same error)...

@rbudnar
Copy link

rbudnar commented Dec 15, 2016

After much of the exact same grief with the DesignTimeProviderServicesAttribute error on scaffolding, I was able to reverse engineer a MySQL database using a different provider: https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql

I ran across this provider on the microsoft docs site https://docs.microsoft.com/en-us/ef/core/providers/pomelo/. Good luck!

@rbudnar
Copy link

rbudnar commented May 22, 2017

@lindeberg Assuming you have both Pomelo.EntityFrameworkCore.MySql and Pomelo.EntityFrameworkCore.MySql.Design installed, have you tried restarting VS? I think you should be pretty much good to go with what you have there. Your command looks about the same as mine:

Scaffold-DbContext "server=server;userid=user;pwd=pass;port=3306;database=db;sslmode=none;" Pomelo.EntityFrameworkCore.MySql -o Models/subfolder

@lindeberg
Copy link

lindeberg commented May 22, 2017

@rbudnar Sorry, and thank you, didn't have .Design, been a long day. By the way, it's been a while since you used this - do you think it's production ready?

@rbudnar
Copy link

rbudnar commented May 22, 2017

@lindeberg I've been using it for a while and haven't run into any real issues with it - of course I'm doing anything huge with it either, but it has been working well for me. Maybe take a look at their issues and see if anything there is a red flag for you? https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues Of course, I don't want to spam up this repo talking about another one, my apologies :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants