ODP.NET Core - 腳手架數據庫上下文
我正在使用 oracles odp.net core beta 3。具體來說,該 dll 是 Oracle.ManagedDataAccess.Core.2.12.0-beta3。該項目是創建一個位於 oracle 實例之上的 Web api。
我的問題 - 此提供程序是否支持命令“Scaffold-DBContext”。如果是這樣,我做錯了什麼…我嘗試使用類似於以下內容的連接字元串。
Data Source={databasename}/{TNS}.domain.local; User ID={UserName};Password={Password};以及 Package Manager 終端中的實際命令
Scaffold-DbContext Data Source={databasename}/{TNS}.domain.local; User ID={UserName};Password={Password};" Oracle.ManagedDataAccess -OutputDir Models -Tables {TableName}我收到以下錯誤,這表明它無法在提供程序程序集中使用 DesignTimeServiceAttribute。
我還引用了 Microsoft.EntityFrameworkCore.Tools (2.2.0),其中包括設計工具。
錯誤
System.InvalidOperationException: Unable to find expected assembly attribute named DesignTimeProviderServicesAttribute in provider assembly Oracle.ManagedDataAccess. This attribute is required to identify the class which acts as the design-time service provider factory. 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_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)
即使下載了用於生產的 ODP.NET Core 驅動程序(2.18.3,於 2018 年 9 月 20 日發布,可從https://www.nuget.org/packages/Oracle 上的 nuget 獲得,我也遇到了您遇到的問題。 ManagedDataAccess.Core/ )。
我聯繫了 Oracle 社區尋求幫助。一個善良的人回答說,如果我們想隨時獲得諸如“UseOracle”之類的好處,還有另一個難題。它是 Entity Framework Core 的 Oracle 提供者。請參閱https://community.oracle.com/thread/4180739上的主題。
據我所知並根據他的回答,使用它的唯一其他方法是 Oracle 幫助中心,ODP.NET Core 入門(https://www.oracle.com/webfolder/technetwork/tutorials )中描述的方式/obe/db/dotnet/ODPNET_Core_get_started/index.html)。