DjD*_*DjD 7 .net c# oracle ado.net
我在 VS2015 中开发了基于实体框架的 Web 服务代码,该代码一直运行良好 - 直到我的系统被新系统替换。在全新的系统上,我无法在同一版本的 Visual Studio 中编译代码,即使我安装了所有依赖项 - 包括 Oracle 11.2 客户端运行时(它说,“安装用于开发应用程序、网络服务和基本客户端软件”)。
当我在VS2015中构建解决方案时,抛出的错误是:Error 175: The ADO.NET provider with invariant name 'Oracle.DataAccess.Client' is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details.
双击该错误会将我带到指向的 EDMX 文件和 EDMX 文件标记 StorageModels > Schema:
<Schema Namespace="Model.Store" Alias="Self" Provider="Oracle.DataAccess.Client" ProviderManifestToken="11.2" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
有趣的是,DLL 文件被创建了(尽管存在上述错误),但是当我用这个新的 DLL 替换服务器上现有的 DLL 时,从数据库中提取数据时似乎出现了问题,如下所示:
System.ArgumentException: The specified store provider cannot be found in the configuration, or is not valid. ---> System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.
at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
--- End of inner exception stack trace ---
at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)
at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config)
at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel()
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
at System.Linq.Queryable.Where[TSource](IQueryable`1 source, Expression`1 predicate)
at MyCo.MyDept.MyIntegration.MyService.DataAccess.DAL.GetLocation() in C:\Users\xxxx\MyCo.MyDept.MyIntegration.MyService\DataAccess\DAL.cs:line 17
at MyCo.MyDept.MyIntegration.MyService.Utility.Helpers.GetLocations() in C:\Users\xxxx\MyCo.MyDept.MyIntegration.MyService\Utility\Helpers.cs:line 303
at MyCo.MyDept.MyIntegration.MyService.KService.GetLocations() in C:\Users\xxxx\MyCo.MyDept.MyIntegration.MyService\KService.svc.cs:line 71
Run Code Online (Sandbox Code Playgroud)
我尝试过其他类似线程中提供的解决方案,但似乎都不起作用。任何帮助表示赞赏。谢谢。
答案很晚,但如果您将 Visual Studio 与 Oracle 连接,这种情况仍然会经常出现。如果您反复安装和卸载 ODT 并且仍然收到此错误,这对我有用:
运行 Visual Studio 2019。
小智 1
检查一下配置文件中是否有以下内容。如果没有相应地添加它们。
已管理数据访问<configSection>
<configSections><section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" /></<configSections>
Run Code Online (Sandbox Code Playgroud)提供者下<entityFramework>
<entityFramework>
<providers>
<provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</providers></entityFramework>
Run Code Online (Sandbox Code Playgroud)请在下面提供工厂详细信息<system.data>
<system.data>
<DbProviderFactories>
<remove invariant="Oracle.ManagedDataAccess.Client"/>
<add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
</DbProviderFactories>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14151 次 |
| 最近记录: |