How do I remove "" from generated SQL? when using EF Core

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
Skippermix
Posts: 4
Joined: Mon 27 Mar 2017 14:01

How do I remove "" from generated SQL? when using EF Core

Post by Skippermix » Wed 19 Jun 2019 12:10

I am trying to use EF Core with the 9.7.734 EFCore driver

I have the following Model

Code: Select all

    [Table("Analysis")]
    public class Analysis
    {
        public long Id { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
        public bool IsActive { get; set; }
        public long SortOrder { get; set; }
    }
And this DbContext

Code: Select all

public DbSet<Analysis> Analyses { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder
                .UseLoggerFactory(MyLoggerFactory)
                .EnableSensitiveDataLogging(true)
                .UseOracle(@"User Id=genshop;Password=xxx;Server=xxx;Sid=xxx;Direct=True;Persist Security Info=True");
        }

But when I query using EF Core I get the following SQL generated

Code: Select all

SELECT "x"."Id", "x"."Name", "x"."Description", "x"."IsActive", "x"."SortOrder"
FROM "Analysis" "x"
WHERE "x"."IsActive" = 1
How do I stop it from adding the " " around everything, as this does not work but
this does

Code: Select all

SELECT x.Id, x.Name, x.Description, x.IsActive, x.SortOrder
FROM Analysis x
WHERE x.IsActive = 1

Oracle is not case sensitive so writing

select * from aNaLysIs
should result in the same as
select * from Analysis

but not when the "Analysis" then casing matters, and I dont want to add [Table("ANALYSIS")] and [Column(.....)] to every model. And at the moment I just get "Table does not exist" or column naming issues

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: How do I remove "" from generated SQL? when using EF Core

Post by Shalex » Wed 19 Jun 2019 17:34

Please set the following option in your code in a static context constructor or before the first context usage:

Code: Select all

    var config = Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig.Instance;
    config.Workarounds.DisableQuoting = true;
Refer to https://www.devart.com/dotconnect/oracl ... tions.html.

Post Reply