ODP.NET Core-脚手架数据库上下文 [英] ODP.NET Core - Scaffold DB-Context

查看:174
本文介绍了ODP.NET Core-脚手架数据库上下文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用oracles odp.net core beta3.具体地说,该dll是Oracle.ManagedDataAccess.Core.2.12.0-beta3.该项目将创建一个位于oracle实例之上的Web api.

I am working with oracles odp.net core beta 3. Specifically, The dll is Oracle.ManagedDataAccess.Core.2.12.0-beta3. The project is to create a web api that sits on top of an oracle instance.

我的问题-此提供程序是否支持命令"Scaffold-DBContext".如果是这样,那我在做什么错...我已经尝试使用类似于以下内容的连接字符串.

My question - Is the command "Scaffold-DBContext" supported with this provider. If so what am I doing wrong... I've made the attempt using a connection string similar to the following.

Data Source={databasename}/{TNS}.domain.local; User ID={UserName};Password={Password};

以及Package Manager终端中的实际命令

And the actual command in the Package Manager terminal

Scaffold-DbContext Data Source={databasename}/{TNS}.domain.local; User ID={UserName};Password={Password};" Oracle.ManagedDataAccess -OutputDir Models -Tables {TableName}

我收到以下错误,这提示它无法在提供程序程序集中喜欢DesignTimeServiceAttribute.

I get the following error which sugests it cannot fond a DesignTimeServiceAttribute in the provider assembly.

我还引用了Microsoft.EntityFrameworkCore.Tools(2.2.0),其中包括设计工具.

I also have Microsoft.EntityFrameworkCore.Tools (2.2.0) referenced which includes the design tools.

错误

    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日发布并提供),我也遇到了您遇到的问题.来自nuget的 https://www.nuget.org/packages/Oracle.ManagedDataAccess.Core /).

I experienced the problems that you experienced, even after downloading the ODP.NET Core driver for production (2.18.3, released on 20-Sept-2018 and available from nuget at https://www.nuget.org/packages/Oracle.ManagedDataAccess.Core/).

我联系了Oracle社区寻求帮助.一个善良的灵魂回答说,如果我们想立即获得善良,例如"UseOracle",那还有另一个难题.它是Entity Framework Core的Oracle提供程序.请参阅 https://community.oracle.com/thread/4180739 上的线程.

I contacted the Oracle community for help. A kind soul answered that there's another piece of the puzzle if we want to have a ready access to goodness such as "UseOracle." It is the Oracle provider for the Entity Framework Core. See the thread at https://community.oracle.com/thread/4180739.

据他所知,根据他的回答,使用它的唯一其他方法是Oracle帮助中心"ODP.NET Core入门"(

The only other way to use it, to my knowledge and based on his answer, is the way described in the Oracle Help Center, Getting Started with ODP.NET Core (https://www.oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/ODPNET_Core_get_started/index.html).

这篇关于ODP.NET Core-脚手架数据库上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆