Efcore: ORA-00923: FROM keyword not found where expected

Created on 23 Nov 2017  路  6Comments  路  Source: dotnet/efcore

I have applications made in .Net461, which use Oracle Database.
I decided to test EFCore, If the tables are created with the EnsureCreated it works, more if I run the migration, I found the error, I followed all the steps. I downloaded the fonts and followed the steps correctly, where I'm failing.

Line meeting the problem is:

at OracleSample.Program.Main(String[] args) na C:\Users\Manfred\Source\MyTestOracle\Programa.cs:linha 17</StackTrace><ExceptionString>Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-00923: FROM keyword not found where expected 

In my searches I only found this:
http://www.dba-oracle.com/t_ora_00923_from_keyword_not_found_where_expected.htm

Steps to reproduce

Steps create database:

https://github.com/aspnet/EntityFrameworkCore/tree/dev/samples/OracleProvider

sqlplus / as sysdba

CREATE PLUGGABLE DATABASE oracle_ef_core
ADMIN USER manfred IDENTIFIED BY manfred
ROLES = (DBA)
FILE_NAME_CONVERT = ('pdbseed', 'pdb_oracle_ef_core');

ALTER PLUGGABLE DATABASE oracle_ef_core OPEN;

My Programs.cs file:

```c#
using System;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Logging;

namespace MyTestOracle
{
class Program
{
static void Main(string[] args)
{
using (var db = new MyTestOracleContext())
{
db.Database.EnsureCreated();
db.Database.Migrate();
}
Console.ReadKey();
}
}

public class MyTestOracleContext : DbContext
{
    public DbSet<Blog> Blogs { get; set; }
    public DbSet<Post> Posts { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseOracle("DATA SOURCE=127.0.0.1:1521/oracle_ef_core;USER ID=manfred;PASSWORD=manfred");
    }
}

public class Blog
{
    public int BlogId { get; set; }
    public string Url { get; set; }
    public int Rating { get; set; }
    public List<Post> Posts { get; set; }
}

public class Post
{
    public int PostId { get; set; }
    public string Title { get; set; }
    public string Content { get; set; }

    public int BlogId { get; set; }
    public Blog Blog { get; set; }
}

}
```
Create migration:

PM> Add-Migration -name MyFirstMigration -Context MyTestOracleContext

Further technical details

EF Core version: (2.1-sources)
Database Provider: (Microsoft.EntityFrameworkCore.Oracle)
Operating system:
IDE: (Visual Studio 2017)

closed-fixed type-bug

All 6 comments

The exact cause of exception would be seen in SQL logs.
Follow this sample on how to enable logging. https://github.com/smitpatel/EFSampleApp/blob/nightly/EFSampleApp/Program.cs

Regardless,
Using EnsureCreated() & Migrate() both together is not invalid. See https://github.com/aspnet/EntityFrameworkCore/issues/10197

@smitpatel, in fact, this does not work.
That happened to me.
This error is trying to execute this SqlServer command:

SELECT OBJECT_ID (N '__ EFMigrationsHistory')

Is there a PR of my for this: https://github.com/aspnet/EntityFrameworkCore/pull/10219

As the project came from the base of SqlServer, there were several places still with commands for SQLServer.
Pr corrected this and many other things.

@smitpatel,
I forgot to inform you that you could comment the EnsureCreated() line.
I was testing, as I said when I launch EnsureCreated (), it works.
More migrations do not.

Looks like this will get fixed by the PR from @ralmsdeveloper. Assigning to @bricelam who is handling that PR.

@ajcvickers any news?

Sorry for the delay. I should get to the PR next week 馃

Was this page helpful?
0 / 5 - 0 ratings