6

I have an annoying problem and can't seem to figure out what's causing it. On my machine when I try to use Update Model from Database... on Edmx file in EF Database first approach the autogenerated model has blank lines between properties. This doesn't seem to occure on other developers machines even though we have same versions of VS , extensions etc.

Problem is that even when I add for example one new table the refresh automatically adds blank lines for all mapped tables. Later all of this is visible as conflict during merge operations in GIT.

Would really appreciate any help since I did't find a single shred of information on this issue anywhere and this really disrupts work.

cah1r
  • 1,751
  • 6
  • 28
  • 47

2 Answers2

3

What worked for me

Turns out it was how my OS was ending lines

  1. Working in Windows. Earlier disabled "auto carriage returns (CR) + line feeds (LF) line endings" in global Git configuration, reenabled:
    git config --global core.autocrlf true
    

    FYI 'nix/Mac ends lines w/ LFs only, Windows end lines w/ CRs + LFs

  2. Opened up *DataModel.tt and *DataModel.Context.tt in Notepad++
  3. Edit > EOL Conversions > Windows (CR LF) > Save
  4. Refresh EDMX

Looking for a better terminal-based solution, sounds like dos2unix will come in to play at some point. Will amend this as soon as I've ironed this out.

fusion27
  • 2,396
  • 1
  • 25
  • 25
2

I checked the files (Model.tt on my machine and my friends) using Notepad++ comparer and it said there are no differences but the encoding is different. When I copied Model.tt manually and did the update the blank lines were gone.... Must be some kind of quirk.

Posting as an answer since I wasted few hours on this and someone might have simmilar problem.

cah1r
  • 1,751
  • 6
  • 28
  • 47
  • What exact problem is? I dont know how to resolve in my case. – Vunb Aug 09 '18 at 09:33
  • 1
    @Vunb Model.tt file encoding might be different in your case same as it was in mine. We fixed it by copying Model.tt content from main repository. This is something that may not be picked up by version control as a change so you have to do it manually. Also maybe this method might be used: https://stackoverflow.com/questions/132318/how-do-i-correct-the-character-encoding-of-a-file. In summary: make sure there is the same file encoding on all machines for Model.tt – cah1r Aug 09 '18 at 09:40
  • I had this same issue on 2 separate laptops being different to the rest of the team, I also resolved by manually downloading the individual tt files from the repo (devops in this case) and overwriting my local files. – F Dev Oct 24 '22 at 04:18