Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6354187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:32:14+00:00 2026-05-24T22:32:14+00:00

I am having a c#.Net desktop application in which I use Linq as ORM

  • 0

I am having a c#.Net desktop application in which I use Linq as ORM and SQL server Express as my database. So, when I use dataContext.CreateDatabase() method, 90 % of the times it is creating the columns in the same order as in linq.cs. In that remaining 10%, the order of the few columns is jumbled. (percentages mentioned are approximate. Linq.cs is generated from SqlMetal)

Is there a specific reason why it happens or is there some setting for controlling that..?
I thought of using the order since the number columns is around 30. And there are 15 to 20 tables as such.

UPDATE

We are using the database in a hybrid way(i.e., also execute SQL commands directly). That is one reason why i am looking for order of columns.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:32:15+00:00Added an answer on May 24, 2026 at 10:32 pm

    In its internals, LINQ-to-SQL uses the SQL language. When it creates tables, if you log your SQL Server, you will see SQL statements, like ALTER TABLE ADD COLUMN…

    ADD COLUMN does not allow setting a column position. More generally, SQL (the language, weather it’s Oracle, MySQL or SQLServer) does not provide tools to control columns position, so the order of the columns is only dependent on the order in which they have been created.

    This behavior is intended. You should not rely on column order ever. Most data access frameworks explicitly advice against it and they don’t guarantee the constancy of the order of columns you have at any point.

    Plus, in your case, you’re using LINQ-to-SQL, so unless you are going to use it in an hybrid way (ie also execute SQL commands directly), order will not matter, since you will access columns through corresponding named properties.

    So, if indeed you use it in an hybrid way, be sure to always specify column names when you execute SqlCommands. Do not write INSERT INTO MYTABLE VALUES (1,2,3), write instead INSERT INTO MYTABLE(COL1, COL2, COL3) VALUES (1,2,3).

    Also, I don’t quite understand why you say you are going to use order since there are 30 columns. First, 30 is not high (neither is 20 tables), and second, if they can be called by their position (like ADDRESS1, ADDRESS2, ADDRESS3) generally it means that the database design is flawed. See 1st normal form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble deploying .NET application which uses Microsoft Access automation. I've installed the
I've an asp.net page having a server side submit button and 2 textboxes which
I am currently working on a VB.NET desktop application that uses .mdb (Access) database
I'm having an issue with SQL Server, I have 2005 installed on my desktop
I am having VB.net dll files which I need to use in Android and
I'm having a simple ASP.NET application hosted on my local IIS6, under Vista. It
Background - If I am building a WPF desktop application (VS2010 & .NET 4)
I'm having trouble with this graphic in Chrome 16 and Safari 5 Desktop: http://jsfiddle.net/D7ERH/embedded/result/
net application. .exe generated is sufficient to use software. since I have 700 MB
i'm developing a .net winforms desktop application intended to be run at several bank's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.