-1

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.

PMerlet
  • 2,568
  • 4
  • 23
  • 39
  • Are you asking about the auto-generated code that no-one is supposed to modify because it will be discarded at the next build? Why would you care about formatting in this case? – Panagiotis Kanavos Dec 08 '16 at 09:51
  • I care about it because I want to be able to check that the pending changes in my solution actually match what I want to do without checking the changes in all the files that have only the format changed – PMerlet Dec 08 '16 at 09:54
  • You should check the *actual* code then - the edmx file. – Panagiotis Kanavos Dec 08 '16 at 09:55
  • I agree with you that the logic will be the same but my question is related to the noise created by these files in my version control system – PMerlet Dec 08 '16 at 09:56
  • 1
    Are you using git? Is there an extra newline in your edmx? Or `\r` and `\n` mixup? The difference seems to be an extra newline. Newlines in a template do end up in the final source and can cause such formatting differences. Perhaps the two machines have different newline handling settings? – Panagiotis Kanavos Dec 08 '16 at 10:01
  • Yes I am using Git and this issue seems to be related to the newline handling settings. How can I fix that ? – PMerlet Dec 08 '16 at 10:22
  • You'll have to use the same settings as that other machine. After that, cloning the repo again is the fastest way to fix this and all other similar issues - this problem will appear in other files as well. – Panagiotis Kanavos Dec 08 '16 at 10:40

1 Answers1

0

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.

Community
  • 1
  • 1
PMerlet
  • 2,568
  • 4
  • 23
  • 39
  • i am facing same ,issue , so what i need to do , is cloning, it is solution of this issue . i have already re cloned but issue is same still . it happening with model classes using Entity framework , when doing update from model . – Vivek Shukla Jul 02 '17 at 10:14