Order columns/properties in model

Thread is closed for posting
2 posts, 0 answers
  1. uquandux
    uquandux avatar
    2 posts
    Member since:
    May 2008

    Posted 14 Nov 2012 Link to this post

    Hello everyone,

    I created my database-model using model-first-approach. When creating the database
    I noted that the columns in the .sql-files for creating the database were created in
    alphabetical-order - which made my PrimaryKey (Id) appear somewhere in the middle
    of the tables - and not as modeled in the diagram at the start.

    Is there a way to order columns within the database-model (not alphabetical) and to
    create the sql-scripts exactly in this order? Is it standard within the rlinq-file that
    columns are ordered alphabetically in general? How to change?

    Thanks in advance,

  2. Dimitar Tachev
    Dimitar Tachev avatar
    67 posts

    Posted 16 Nov 2012 Link to this post


    In general when you use model first scenario there are two options to change the order of the columns in your database model:

    1) You could use our API for handling schema migrations programmatically to set the order of the columns in your database the same as the order in your domain model. The detail you should have in mind in this case is that if you have some associations between your tables you should also enable creation of foreign key constraints. For your convenience I created a sample application which illustrates that API - find it attached.

    2) If you don’t want to use the order of the columns in your domain classes you could choose to update database from model wizard. At the summary page choose “Create Script File” instead of “Create Script File and Execute”. Then you could manually reorder the columns in the generated script file and execute it.

    I will be happy to assist you if you have further questions.

    Kind regards,
    Dimitar Tachev
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
Back to Top