none
Entity Framework Capitalization RRS feed

  • Question

  • Why does Entity Framework capitalize all table and field names when it creates a data model based on an existing database?

    Is there any way to turn that off and bring in the tables and fields with the same capitalization that the actual database has?

    • Moved by Amanda Zhu Wednesday, August 27, 2014 3:26 AM
    Wednesday, August 27, 2014 12:37 AM

Answers

  • Hello FireStorm2012,

    >>Why does Entity Framework capitalize all table and field names when it creates a data model based on an existing database?

    What version Entity Framework are you working with? I test with Entity Framework 5 and 6 with below example:

    CREATE TABLE [dbo].[student] (
    
        [id]   INT        NOT NULL,
    
        [name] NCHAR (10) NULL,
    
        [sex] NCHAR(10) NULL, 
    
        [age] NCHAR(10) NULL, 
    
        [value] NCHAR(10) NULL, 
    
        PRIMARY KEY CLUSTERED ([id] ASC)
    
    );
    

    You could see that its table and columns names are all lowercase. After importing it from database to the data model, it doesn’t capitalize all table and field names in my side:

    public partial class student
    
        {
    
            public int id { get; set; }
    
            public string name { get; set; }
    
            public string sex { get; set; }
    
            public string age { get; set; }
    
            public string value { get; set; }
    
        }
    

    If you are working with early version, you could try to upgrade it to 5 or later.

    Best Regards,

    Fred.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by FireStorm2012 Wednesday, August 27, 2014 6:07 PM
    Wednesday, August 27, 2014 5:56 AM
    Moderator

All replies

  • Hi,

    Because your issue is related to Entity Framework,I moved this thread to ADO.NET Entity Framework and LINQ to Entities forum for better support.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, August 27, 2014 3:27 AM
  • Hello FireStorm2012,

    >>Why does Entity Framework capitalize all table and field names when it creates a data model based on an existing database?

    What version Entity Framework are you working with? I test with Entity Framework 5 and 6 with below example:

    CREATE TABLE [dbo].[student] (
    
        [id]   INT        NOT NULL,
    
        [name] NCHAR (10) NULL,
    
        [sex] NCHAR(10) NULL, 
    
        [age] NCHAR(10) NULL, 
    
        [value] NCHAR(10) NULL, 
    
        PRIMARY KEY CLUSTERED ([id] ASC)
    
    );
    

    You could see that its table and columns names are all lowercase. After importing it from database to the data model, it doesn’t capitalize all table and field names in my side:

    public partial class student
    
        {
    
            public int id { get; set; }
    
            public string name { get; set; }
    
            public string sex { get; set; }
    
            public string age { get; set; }
    
            public string value { get; set; }
    
        }
    

    If you are working with early version, you could try to upgrade it to 5 or later.

    Best Regards,

    Fred.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by FireStorm2012 Wednesday, August 27, 2014 6:07 PM
    Wednesday, August 27, 2014 5:56 AM
    Moderator
  • I am using version 6.
    Wednesday, August 27, 2014 4:45 PM
  • Thank you for your help. As it turns out, the tables and fields in question are indeed all capitalized in the SQL database. I am working with Dynamics AX, where the tables and fields are shown in camel case--or however entered by developers in it's IDE. So it's AX that's capitalizing them, not Entity Framework.
    Wednesday, August 27, 2014 6:07 PM