用Scaffold命令生成数据库实体类,新建个asp.net core 2.2 webapi项目,在.net core 2.2下是好的,能生成实体类。再新建asp.net core 3.0 webapi项目,关联的驱动和组件都升级到3.0 预览版,同样的Scaffold命令就报错了,不知道问题再哪里?目前就现在2.2里生成实体类,在复制到3.0的项目中用。
PM> Scaffold-DbContext -Force "Data Source=xx;Database=cloud;User Id=xx;Password=xx;CharSet=utf8;port=xx" MySql.Data.EntityFrameworkCore -OutputDir Models -Context MySqlContext
System.TypeLoadException: Method 'Create' in type 'MySql.Data.EntityFrameworkCore.Scaffolding.Internal.MySQLDatabaseModelFactory' from assembly 'MySql.Data.EntityFrameworkCore, Version=8.0.17.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, IEnumerable1 schemas, IEnumerable1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable1 schemaFilters, IEnumerable1 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.
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.17.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' does not have an implementation.
PM> Scaffold-DbContext -Force "Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = xx)(PORT=xx))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME =xx)));User Id=xx;Password=xx;" Oracle.EntityFrameworkCore -OutputDir DataModels -Context MyDbContext -Schemas xx
System.TypeLoadException: Method 'Create' in type 'Oracle.EntityFrameworkCore.Scaffolding.Internal.OracleDatabaseModelFactory' from assembly 'Oracle.EntityFrameworkCore, Version=2.0.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342' does not have an implementation.
at Oracle.EntityFrameworkCore.Design.Internal.OracleDesignTimeServices.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, IEnumerable1 schemas, IEnumerable1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable1 schemaFilters, IEnumerable1 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.
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Method 'Create' in type 'Oracle.EntityFrameworkCore.Scaffolding.Internal.OracleDatabaseModelFactory' from assembly 'Oracle.EntityFrameworkCore, Version=2.0.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342' does not have an implementation.
Steps to reproduce
Include a complete code listing (or project/solution) that we can run to reproduce the issue.
Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.
--mysql (replace sensitive information to xx)
Scaffold-DbContext -Force "Data Source=xx;Database=cloud;User Id=xx;Password=xx;CharSet=utf8;port=xx" MySql.Data.EntityFrameworkCore -OutputDir Models -Context MySqlContext
--oracle (replace sensitive information to xx)
Scaffold-DbContext -Force "Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = xx)(PORT=xx))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME =xx)));User Id=xx;Password=xx;" Oracle.EntityFrameworkCore -OutputDir DataModels -Context MyDbContext -Schemas xx
Further technical details
$ dotnet --info
.NET Core SDK (global.json):
Version: 3.0.100-preview8-013656
Commit: 8bf06ffc8d
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview8-013656
Host (useful for support):
Version: 3.0.0-preview8-28405-07
Commit: d01b2fb7bc
.NET Core SDKs installed:
2.1.801 [C:\Program Files\dotnet\sdk]
2.2.300 [C:\Program Files\dotnet\sdk]
2.2.401 [C:\Program Files\dotnet\sdk]
3.0.100-preview8-013656 [C:\Program Files\dotnet\sdk]
IDE: (Visual Studio Community 2019 16.2.3)