Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

facing issue in connectivity with Entity Framework6 and Oracle 11g

2950288May 14 2015 — edited May 15 2015

Hi,

i am facing issue when trying to connect entity framework 6 with oracle 11g.

ERROR:

{"An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct."}


StackTrace:

   at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)

   at System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.<>c__DisplayClass1.<ResolveManifestToken>b__0(Tuple`3 k)

   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 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.RetryLazy`2.GetValue(TInput input)

   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()

   at System.Data.Entity.Internal.InternalContext.Initialize()

   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.FirstOrDefault[TSource](IQueryable`1 source)

   at TestApplication.Program.Main(String[] args) in c:\Users\ajay.chigurupati\Downloads\EntityFramework_Oracle_sample-master\TestApplication\Program.cs:line 18

   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)

   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

   at System.Threading.ThreadHelper.ThreadStart()

My APP.Config:

<?xml version="1.0" encoding="utf-8"?>

<configuration>

  <configSections>

    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->

    <section name="entityFramework"

      type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

      requirePermission="false"/>

    <section name="oracle.manageddataaccess.client"

      type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>

  </configSections>

  <startup>

    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>

  </startup>

  <connectionStrings>

    <clear/>

 

    <!--<add name="OracleDbContext" providerName="Oracle.ManagedDataAccess.Client"

      connectionString="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.59.103)(PORT=49161)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XE)));User Id=system;Password=oracle"/>

  </connectionStrings>-->

    <add name="OracleDbContext" providerName="Oracle.ManagedDataAccess.Client"

      connectionString=" Data Source=HRFOLATEST1;User ID=hrms2;Password=hrms2;"/>

  

  </connectionStrings>

  <entityFramework>

    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>

    <providers>

      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>

      <provider invariantName="Oracle.ManagedDataAccess.Client"

        type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>

    </providers>

  </entityFramework>

  <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.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>

    </DbProviderFactories>

  </system.data>

  <runtime>

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

      <dependentAssembly>

        <publisherPolicy apply="no"/>

        <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral"/>

        <bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.121.2.0"/>

      </dependentAssembly>

    </assemblyBinding>

  </runtime>

</configuration>

My Db Context:


class DatabaseContext : DbContext

    {

        public DatabaseContext()

            : base("OracleDbContext")

        {

        }

        public DbSet<User> Users { get; set; }

       

        protected override void OnModelCreating(DbModelBuilder modelBuilder)

        {

            //Configure domain classes using modelBuilder here

            modelBuilder.Entity<User>().ToTable("HRMS_OLAS_TREE");

            modelBuilder.Entity<User>().Property(user => user.ID).HasColumnName("EMP_ID").HasColumnType("VARCHAR");

            modelBuilder.Entity<User>().Property(user => user.NAME).HasColumnName("EMP_NAME").HasColumnType("VARCHAR");

            base.OnModelCreating(modelBuilder);

        }

    }

    internal class User

    {

        public long ID { get; set; }

        public string NAME { get; set; }

    }

Please let me now what mistake i am doing.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 12 2015
Added on May 14 2015
5 comments
3,995 views