2
votes

I am developing an ASP.NET MVC 5 application with EF6 and Oracle database.

I am using the code First approach, I created my entities and My Context class and then I tried the Enable and Add a Migration but I got this error.

However, If I use SQL SERVER in the place of Oracle database it works fine but not with Oracle database.

This is the error:

System.Data.Entity.Core.ProviderIncompatibleException: An error occurred accessing the database. 
This usually means that the connection to the database failed. Check that the connection string is correct and that the appropriate

DbContext constructor is being used to specify it or find it in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=386386 for information on DbContext and connections. See the inner exception for details of the failure. ---> System.Data.Entity.Core.ProviderIncompatibleException: The provider did not return a ProviderManifestToken string. ---> Oracle.ManagedDataAccess.Client.OracleException: ORA-12154: TNS : impossible de résoudre l'identificateur de connexion indiqué ---> OracleInternal.Network.NetworkException: ORA-12154: TNS : impossible de résoudre l'identificateur de connexion indiqué at OracleInternal.Network.AddressResolution..ctor(String TNSAlias, String instanceName) at OracleInternal.Network.OracleCommunication.DoConnect(String tnsDescriptor) at OracleInternal.Network.OracleCommunication.Connect(String tnsDescriptor, Boolean doNAHandshake, String IName) at OracleInternal.ServiceObjects.OracleConnectionImpl.Connect(ConnectionString cs, Boolean bOpenEndUserSession, OracleConnection connRefForCriteria, String instanceName) --- End of inner exception stack trace --- at OracleInternal.ConnectionPool.PoolManager3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch) at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch) at OracleInternal.ConnectionPool.OracleConnectionDispenser3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, OracleConnection connRefForCriteria) at Oracle.ManagedDataAccess.Client.OracleConnection.Open() at Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices.GetDbProviderManifestToken(DbConnection connection) at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) --- End of inner exception stack trace --- at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection) --- End of inner exception stack trace --- at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection) at System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.<>c__DisplayClass1.b__0(Tuple3 k) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection connection) at System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) at System.Data.Entity.Internal.RetryLazy2.GetValue(TInput input) at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() at System.Data.Entity.Internal.LazyInternalContext.get_ModelBeingInitialized() at System.Data.Entity.Infrastructure.EdmxWriter.WriteEdmx(DbContext context, XmlWriter writer) at System.Data.Entity.Utilities.DbContextExtensions.<>c__DisplayClass1.b__0(XmlWriter w) at System.Data.Entity.Utilities.DbContextExtensions.GetModel(Action`1 writeXml) at System.Data.Entity.Utilities.DbContextExtensions.GetModel(DbContext context) at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext, DatabaseExistenceState existenceState, Boolean calledByCreateDatabase) at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration) at System.Data.Entity.Migrations.Design.MigrationScaffolder..ctor(DbMigrationsConfiguration migrationsConfiguration) at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.RunCore() at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run() An error occurred accessing the database. This usually means that the connection to the database failed. Check that the connection string is correct and that the appropriate DbContext constructor is being used to specify it or find it in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=386386 for information on DbContext and connections. See the inner exception for details of the failure*.

And this is my connection string:

<connectionStrings>
    <add name="BiatContext" providerName="Oracle.ManagedDataAccess.Client" connectionString="User Id=SYSTEM;Password=admin;Data Source=oracle" />
</connectionStrings>
1
Getting similar exception. Any helpJohny Bravo

1 Answers

0
votes

You must change your connection string like this

<connectionStrings>
        <add name="BiatContext" providerName="Oracle.ManagedDataAccess.Client" connectionString="User Id=SYSTEM;Password=admin; Min Pool Size=20; Max Pool Size=200; Connection Lifetime=120;Connection Timeout=70;Incr Pool Size=2; Decr Pool Size=3;Data Source=oracle" />
</connectionStrings>