Entity framework core beta - how to avoid quotes being generated in sql — oracle-tech

    Forum Stats

  • 3,715,657 Users
  • 2,242,821 Discussions
  • 7,845,481 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Entity framework core beta - how to avoid quotes being generated in sql

user5716448
user5716448 Member Posts: 1,683 Silver Badge
edited April 2019 in ODP.NET

Hi,

using entity framework core beta and getting table or view does not exist as quotes being generated in the sql and this alos gives same error when run on database.

How can we ensure ef core beta generates the sql without quotes around the identifier thus allowing the sql to work e.g is there a disable quotes switch or something similar?

   at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.ExecuteAsync(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues, CancellationToken cancellationToken)

Microsoft.EntityFrameworkCore.Database.Command:Error: Failed executing DbCommand (137ms) [Parameters=[], CommandType='Text', CommandTimeout='0']

SELECT "m"."MULT_MULTIPLE_CODE", "m"."MULT_ANMW_MULTIPLE_CODE", "m"."MULT_AUTH_REQUIRED", "m"."MULT_JMW_MULTIPLE_TYPE_CODE", "m"."MULT_LINK_MULTIPLE_CODE", "m"."MULT_NAME", "m"."MULT_PROM_AUTH_REQUIRED", "m"."MULT_SELECTED_MULTIPLE"

FROM "Multiple" "m"

As a workaround changed the text in the solution to MULTIPLE rather than Multiple and gets past this stage

next error is The expected type was 'System.Int32' but the actual value was null.

An exception occurred in the database while iterating the results of a query for context type 'RazorPagesMultiple.Models.RazorPagesMultipleContext'.

RazorPagesMultiple>       System.InvalidOperationException: An exception occurred while reading a database value for property 'MULTIPLE.MULT_LINK_MULTIPLE_CODE'. The expected type was 'System.Int32' but the actual value was null. ---> System.NullReferenceException: Object reference not set to an instance of an object.

RazorPagesMultiple>          at Microsoft.EntityFrameworkCore.Metadata.Internal.EntityMaterializerSource.TryReadValue[TValue](ValueBuffer& valueBuffer, Int32 index, IPropertyBase property)

RazorPagesMultiple>          --- End of inner exception stack trace ---

How can we resolve this - definition of class below

namespace RazorPagesMultiple.Models

{

    //public class Multiple

    public class MULTIPLE

    {

        [Key]

        public int MULT_MULTIPLE_CODE { get; set; }

        [StringLength(60, MinimumLength = 6)]

        [Required] public string MULT_NAME { get; set; }

        public string MULT_SELECTED_MULTIPLE { get; set; }

        public string MULT_ANMW_MULTIPLE_CODE { get; set; }

        public int MULT_LINK_MULTIPLE_CODE { get; set; }

        public string MULT_JMW_MULTIPLE_TYPE_CODE { get; set; }

        public string MULT_AUTH_REQUIRED { get; set; }

        public string MULT_PROM_AUTH_REQUIRED { get; set; }

    }

}

changed int to int?  and got pas this stage.

e1573ab9-3cae-4c35-ae02-e274e0729a97

Answers

  • Alex Keh-Oracle
    Alex Keh-Oracle Posts: 2,751 Employee
    edited April 2019

    The quotes are unavoidable because in almost all cases .NET classes will be mixed case and Oracle DB requires all mixed case object names to be encased in quotes.

    I suppose we could introduce a a setting to make quotes optional, but not sure it provides a marked benefit. Developers choose ORMs for productivity reasons at the sacrifice of customizability among other things.

    user5716448
  • user5716448
    user5716448 Member Posts: 1,683 Silver Badge
    edited April 2019

    Thanks for update. Changed the names of the class in the code to all be upper case such that generates "MULTIPLE" in from clause

Sign In or Register to comment.