visual-studiovisual-studio-2015edmxedmx-designer

VS2015 auto generated code is not correctly formatted


I am using Visual Studio Professional 2015 with Update 3. I have a .edmx file that contains my database model. When I update my model from the database, the auto-generated code is not correctly formatted.

For example, previously I had something like the following :

namespace Something
{
    using System;
    using System.Collections.Generic;

    public partial class Analysis
    {
        public Analysis()
        {
            this.QualitativeAnalysis = new HashSet<QualitativeAnalysis>();
            this.QuantitativeAnalysis = new HashSet<QuantitativeAnalysis>();
            this.ScoringAnalysis = new HashSet<ScoringAnalysis>();
            this.SumupAnalysis = new HashSet<SumupAnalysis>();
        }
    }
}

I changed my machine and now I have :

namespace Something
{

using System;
    using System.Collections.Generic;

    public partial class Analysis
    {

        public Analysis()
        {

            this.QualitativeAnalysis = new HashSet<QualitativeAnalysis>();

            this.QuantitativeAnalysis = new HashSet<QuantitativeAnalysis>();

            this.ScoringAnalysis = new HashSet<ScoringAnalysis>();

            this.SumupAnalysis = new HashSet<SumupAnalysis>();

        }
    }
}

What do I have to change in my VS configuration to fix this issue ?

Thanks.


Solution

  • Based on @Panagiotis Kanavos comments, I figured out this behavior was due to the end of lines settings. Basically, Git stores the files with a Unix setting while Visual Studio reads it with a Microsoft setting.

    I installed the Git for Windows Bash client and after cloning again the repo, it fixed the problem.

    This tool is converting the Unix setting to Microsoft setting on checkout and convert the Microsoft setting to Unix setting on commit.