I have the follow context, mapping and class that uses for work with oracle:
public class Context : DbContext
{
public string Schema { get; set; }
public Context(string connectionString)
: base(connectionString)
{
}
public DbSet<User> UserDbSet { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new UserMapping(Schema));
}
}
public class User
{
public decimal Id { get; set; }
public string Name { get; set; }
public string LastName { get; set; }
}
public class UserMapping : EntityTypeConfiguration<User>
{
public UserMapping(string schema = "dbo")
{
HasKey(t => t.Id);
ToTable(schema + ".TBLUSER");
Property(t => t.Id).HasColumnName("Id");
Property(t => t.Name).HasColumnName("NAME");
Property(t => t.LastName).HasColumnName("LASTNAME");
}
}
But when i call the:
var context = new Context("name=ORACLE")
{
Schema = "USERTABLESPACEDEFAULT"
};
var users = context.UserDbSet.ToList();
The oracle Privider shows me the follow error:
{"ORA-00904: \"Extent1\".\"Id\": invalid identifier"}
And thats is why EntityFrameworks try to execute the follow query:
SELECT
"Extent1"."Id" AS "Id",
"Extent1"."NAME" AS "NAME",
"Extent1"."LASTNAME" AS "LASTNAME"
FROM "USERTABLESPACEDEFAULT"."TBLUSER" "Extent1"
Any .dll its necesary ??
Here is my connectionString:
<add name="ORACLE" connectionString="DATA SOURCE=localhost:1521/XE;PASSWORD=Isolucion2015*;USER ID=SYSTEM" providerName="Oracle.DataAccess.Client" />
Id? Or is itID? Because once the column names are wrapped in double quotes, the name is case sensitive, so you have to get the casing right.