title: Table Does Not Exist while using EF 6 and Oracle.ManagedDataAccess
body: <p>I am creating a MVC application using EF <code>6.0.0.0</code> and ODP.Net <code>Oracle.ManagedDataAccess</code> version <code>4.121.2.0</code> for the data access.</p>
  
  <p>In my <code>Controller</code> called <code>EmployeeController</code>, I have the following code snippet:</p>
  
  <pre><code>public ActionResult Details(int id) {
      try {
          EmployeeContext employeeContext = new EmployeeContext();
          Employee employee = employeeContext.Employees.Single(x =&gt; x.Id == id); //Here the exception occurs!
          return View(employee);
      } catch (Exception e) {
          return View(e);
      }
  }
  </code></pre>
  
  <p>And when I load the <code>Employee/Details.cshtml</code> page I got the following Exception:</p>
  
  <blockquote>
    <p>"An error occurred while executing the command definition. See the
    inner exception for details."</p>
  </blockquote>
  
  <p>And in the inner exception, it says:</p>
  
  <blockquote>
    <p>ORA-00942: table or view does not exist</p>
  </blockquote>
  
  <p>And this puzzles me, since in my Oracle Database, the table definitely exist (I checked using Toad for Oracle):</p>
  
  <p><a href="https://i.stack.imgur.com/yVlBf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yVlBf.png" alt="enter image description here"></a> </p>
  
  <p>The <code>connectionString</code> for the database itself is the same connection string which I use for other project and where I was able to query the data from the database without difficulty.</p>
  
  <p>Here is how my <code>Employee</code> class is declared in the <code>Models/Employee.cs</code>:</p>
  
  <pre><code>using System.ComponentModel.DataAnnotations.Schema;
  .
  .
  .
  [Table("TBLEMPLOYEE")] //the same table name
  public class Employee {
      public int Id { get; set; }
      public string Name { get; set; }
      public string Gender { get; set; }
      public DateTime DateOfBirth { get; set; }
      public int EmployeeType { get; set; }
      public double? AnnualSalary { get; set; }
      public double? HourlyPay { get; set; }
      public double? HoursWorked { get; set; }
      public string City { get; set; }
  }
  </code></pre>
  
  <p>And my <code>Models/EmployeeContext.cs</code> is simply consisting of a single element:</p>
  
  <pre><code>using System.Data.Entity;
  .
  .
  .
  public class EmployeeContext : DbContext {
      public DbSet&lt;Employee&gt; Employees { get; set; }
  }
  </code></pre>
  
  <p>And in the <code>Global.asax.cs</code> file, I have initialized the database for <code>EmployeeContext</code> model:</p>
  
  <pre><code>protected void Application_Start() { //executed at the very beginning               
      Database.SetInitializer&lt;MvcWebApplication1.Models.EmployeeContext&gt;(null); //null -&gt; no initialization strategy
      AreaRegistration.RegisterAllAreas();
      FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
      RouteConfig.RegisterRoutes(RouteTable.Routes);
      BundleConfig.RegisterBundles(BundleTable.Bundles);
  }
  </code></pre>
  
  <p>What am I still getting error should that the Table does not exist? What could possibly go wrong here? Any suggestion how to debug such case?</p>
  
  <p><strong>Edit:</strong> </p>
  
  <p>When I evaluate the <code>employeeContext.Employees</code>, I got the following value:</p>
  
  <pre><code>{SELECT 
  "Extent1"."Id" AS "Id", 
  "Extent1"."Name" AS "Name", 
  "Extent1"."Gender" AS "Gender", 
  "Extent1"."DateOfBirth" AS "DateOfBirth", 
  "Extent1"."EmployeeType" AS "EmployeeType", 
  "Extent1"."AnnualSalary" AS "AnnualSalary", 
  "Extent1"."HourlyPay" AS "HourlyPay", 
  "Extent1"."HoursWorked" AS "HoursWorked", 
  "Extent1"."City" AS "City"
  FROM "dbo"."TBLEMPLOYEE" "Extent1"}
  </code></pre>
  
  <p><strong>Edit 2:</strong></p>
  
  <p>Using:</p>
  
  <pre><code>employeeContext.Database.Log = s =&gt; System.Diagnostics.Debug.WriteLine(s);
  </code></pre>
  
  <p>I got the following in my Debug output window:</p>
  
  <pre><code>SELECT 
  "Extent1"."Id" AS "Id", 
  "Extent1"."Name" AS "Name", 
  "Extent1"."Gender" AS "Gender", 
  "Extent1"."DateOfBirth" AS "DateOfBirth", 
  "Extent1"."EmployeeType" AS "EmployeeType", 
  "Extent1"."AnnualSalary" AS "AnnualSalary", 
  "Extent1"."HourlyPay" AS "HourlyPay", 
  "Extent1"."HoursWorked" AS "HoursWorked", 
  "Extent1"."City" AS "City"
  FROM "dbo"."TBLEMPLOYEE" "Extent1"
  WHERE ("Extent1"."Id" = :p__linq__0) AND (ROWNUM &lt;= (2) )
  </code></pre>
  
  <p><strong>Edit 3:</strong></p>
  
  <p>This is how my connection string looks like, just in case it is needed</p>
  
  <pre><code>  &lt;connectionStrings&gt;
      &lt;add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MvcWebApplication1-20160212010850.mdf;Initial Catalog=aspnet-MvcWebApplication1-20160212010850;Integrated Security=True"
        providerName="System.Data.SqlClient" /&gt;
      &lt;add name="EmployeeContext" connectionString="Data source=thisisfakedatasource;user id=thisisfakename;password=thisisfakepassword;persist security info=True"
        providerName="Oracle.ManagedDataAccess.Client"/&gt;
    &lt;/connectionStrings&gt;  
  </code></pre>
  
  <p>And the settings for the entityFramework is as follow:</p>
  
  <pre><code>  &lt;entityFramework&gt;
      &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"&gt;
        &lt;parameters&gt;
          &lt;parameter value="mssqllocaldb" /&gt;
        &lt;/parameters&gt;
      &lt;/defaultConnectionFactory&gt;
      &lt;providers&gt;
        &lt;provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /&gt;
        &lt;provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" /&gt;
      &lt;/providers&gt;
    &lt;/entityFramework&gt;
  </code></pre>
  
  <p>Any clue where the issue could be?</p>
  
  <p>Additional info:</p>
  
  <p>Exception stack trace:</p>
  
  <pre><code>e.StackTrace
  
     at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
     at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
     at System.Data.Entity.Core.Objects.ObjectQuery`1.&lt;&gt;c__DisplayClass7.&lt;GetResults&gt;b__6()
     at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
     at System.Data.Entity.Core.Objects.ObjectQuery`1.&lt;&gt;c__DisplayClass7.&lt;GetResults&gt;b__5()
     at System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func`1 operation)
     at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
     at System.Data.Entity.Core.Objects.ObjectQuery`1.&lt;System.Collections.Generic.IEnumerable&lt;T&gt;.GetEnumerator&gt;b__0()
     at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
     at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
     at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.&lt;GetElementFunction&gt;b__3[TResult](IEnumerable`1 sequence)
     at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
     at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
     at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)
     at System.Linq.Queryable.Single[TSource](IQueryable`1 source, Expression`1 predicate)
     at MvcWebApplication1.Controllers.EmployeeController.Details(Int32 id) in c:\myapp\Controllers\EmployeeController.cs:line 25
  </code></pre>
  
  <p>Inner exception stack trace:</p>
  
  <pre><code>(e.InnerException).StackTrace
  
     at OracleInternal.ServiceObjects.OracleCommandImpl.VerifyExecution(OracleConnectionImpl connectionImpl, Int32&amp; cursorId, Boolean bThrowArrayBindRelatedErrors, OracleException&amp; exceptionForArrayBindDML, Boolean&amp; hasMoreRowsInDB, Boolean bFirstIterationDone)
     at OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteReader(String commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl, OracleDataReaderImpl&amp; rdrImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64[] scnForExecution, Int64[]&amp; scnFromExecution, OracleParameterCollection&amp; bindByPositionParamColl, Boolean&amp; bBindParamPresent, Int64&amp; internalInitialLOBFS, OracleException&amp; exceptionForArrayBindDML, Boolean isDescribeOnly, Boolean isFromEF)
     at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)
     at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)
     at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
     at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.&lt;Reader&gt;b__c(DbCommand t, DbCommandInterceptionContext`1 c)
     at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
     at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
     at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
     at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
     at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
  </code></pre>