【发布时间】:2018-03-29 16:31:09
【问题描述】:
我正在尝试升级应用程序(从 .net 框架 2.0 到 4.71),但由于无法将 sql/oracle 数据库转换为 system.data.entity.database 而出现错误。
代码如下:
using EntLibContrib.Data.OdpNet;
using Microsoft.Practices.EnterpriseLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
public Database GetDatabase(string name)
{
UMiami.MedResearch.Core.ConnectionString str = this.Retrieve(name);
if (str != null)
{
if (str.ProviderType == "SQL Server")
{
return new SqlDatabase(str.Value);
}
if (str.ProviderType == "Oracle")
{
return new OracleDatabase(str.Value);
}
}
throw new Exception("Connection string was not found.");
}
收到的错误是:
严重性代码描述项目文件行抑制状态 错误 CS0029 无法将类型“Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase”隐式转换为“System.Data.Entity.Database”
严重性代码描述项目文件行抑制状态 错误 CS0029 无法将类型“EntLibContrib.Data.OdpNet.OracleDatabase”隐式转换为“System.Data.Entity.Database”
只有在我为 Release 配置设置解决方案时才会引发错误,如果是 Debug 配置则消失。我该如何解决这个问题?
【问题讨论】:
标签: c# .net visual-studio-2017