我正在尝试使用 ado.net 从 .net core 3.1 连接到 oracle 数据库,这是我的代码
private OracleConnection GetOracleConnection()
{
string conString = "Data Source=Q550.adr.XXXX.com;Persist Security,Info=True;User ID=XXXX;Password=CCC39";
OracleConnection con = new OracleConnection(conString);
return con;
}
Run Code Online (Sandbox Code Playgroud)
但是当这个函数在第 2 行执行以下异常时
System.TypeInitializationException: 'OracleInternal.Common.ProviderConfig' 的类型初始值设定项引发异常
FileNotFoundException:无法加载文件或程序集“System.Configuration.ConfigurationManager,Version=4.0.2.0,Culture=neutral,PublicKeyToken=cc7b13ffcd2ddd51”。该系统找不到指定的文件。**
谁能告诉我这是怎么回事??
将 EF Core 与 Oracle.ManagedDataAccess.Core(2.18.3) 结合使用
尝试添加数据库上下文时无法调用“options.UseOracle”方法。
编译器抛出错误:“DbContextOptionsBuilder”不包含“UseOracle”的定义,并且找不到接受“DbContextOptionsBuilder”类型的第一个参数的可访问扩展方法“UseOracle”(您是否缺少 using 指令或程序集引用?)
请参阅下面的代码,它的最后一行没有编译,我的 nuget 参考包括 Oracle.ManagedDataAccess.Core(2.18.3)
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using EfGetStarted.AspNetCore.NewDb.Models;
using Microsoft.EntityFrameworkCore;
using Oracle.ManagedDataAccess.Client;
namespace EfGetStarted.AspNetCore.NewDb
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{ …Run Code Online (Sandbox Code Playgroud) c# entity-framework-core asp.net-core oracle.manageddataaccess
我在Oracle SQL Developer中有1个包含1的表column as Float。Data reader应该Decimal for oracle float datatype按照此处给出的表返回:https : //docs.microsoft.com/zh-cn/dotnet/framework/data/adonet/oracle-data-type-mappings
但问题是,DataReader的收益double as datatype为Float Column如下图所示:
但是问题是datareader返回的数据类型为double NREAL as Float,NFLOAT1 as float并且令人惊讶的是datareader返回Decimal for both the column如下所示:
代码:
static void Test()
{
using (OracleConnection connection = new OracleConnection("connection string")
{
connection.Open();
using (OracleCommand command = connection.CreateCommand())
{
command.CommandText = "select id , NFLOAT from Numeric_Table";
using (OracleDataReader reader = command.ExecuteReader())
{
for (int i = …Run Code Online (Sandbox Code Playgroud) c# oracle ado.net oracle-sqldeveloper oracle.manageddataaccess
我将 Oracle12c 与用 C# 编写的应用程序一起使用,并使用 Oracle.ManagedDataAccess.dll 来处理数据库连接。
我们的产品在运行多年后偶尔会抛出此异常:
Oracle.ManagedDataAccess.Client.OracleException (0xFFFFFC0C): Pooled connection request timed out
at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword)
at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
Run Code Online (Sandbox Code Playgroud)
我知道这个错误的原因。查看代码,OracleConnection 或 OracleCommand 对象都没有被释放。因此,这些连接正在建立,直到最终抛出此异常。
修复方法很简单。将它们包含在Using语句中。我不需要这方面的帮助。
然而,我感兴趣的是为什么这个问题现在开始了。该软件运行多年没有出现任何问题。他们做了一些数据库维护,更新了同一服务器上的其他软件,然后这个问题就开始了。我不知道他们做了什么 Db 维护。
应用程序中的连接字符串未指定任何池属性。
是否有一个 oracle 数据库设置会导致数据库中的并发连接数减少,从而导致这种情况开始发生?
更新
我编写了一个小测试应用程序来检查限制。它只是循环并打开连接,执行基本查询并且不会释放连接。在我的测试系统上,它在 640 次循环后开始抛出此异常。每次我运行它时,它都会变化给或采取 10 个循环。
是什么设置了这个限制?