1

We are having a problem using TFS GIT and linq2sql/entity framework database first. The issue is with the edml.edmx designer and layout files constantly changing. Merging changes of these files causes multiple conflicts and sometimes data loss if they are not managed correctly.

I realise that the designer and layout files are user specific but can't ignore these files in git as they are dependant files.

Does anyone have any suggestions for a good practice of merging these files.

R Davies
  • 105
  • 1
  • 11

1 Answers1

0

I know this question's a bit stale, but it's relevant to me at the moment. As @ErikEJ mentioned in a comment, you should probably look at migrating to EF Code First (or something along those lines).

That being said, we're having the same issue you've mentioned above. After a bit of research, it appears that the issue (also happens occasionally w/ .csproj files) is a known issue w/ Git's merge driver that apparently hasn't warranted any kind of attention.

It definitely warrant's more hands-on than i'd like, especially for such an unwieldy file. We've gotten away w/ rebuilding the model, however you definitely have to review the results of the change to ensure you didn't lose anything.

Also, {insert shameless plug for keeping your changesets as small as possible}

Edit: Here's some further reading: https://haacked.com/archive/2014/04/16/csproj-merge-conflicts/ if you're interested.

Edit: I've had some luck using the "patience" diff algorithm for doing the merges. it definitely cleans things up with merging XML. It's still not pretty or awesome, but you may want to give it a shot.

From Git merge using recursive strategy and patience option, you can call

git merge -s recursive -X patience other-branch

to execute the merge using the patience algorithm. or you can simply do a diff with the --patience flag.

Finally, you may wish to do some additional reading on the patience algorithm or compare the output of merge conflicts yourself. I've found that I like it better overall and have added it to my global .gitconfig.

Here's some more outside reading if you're interested.

The patience diff algorithm (external)

TIL: Diffing with Patience (external)

Git Source Code Review: Diff Algorithms (external) - includes links to more info from the author of the Patience algorithm, but my corporate proxy is currently blocking me from going there, so I haven't read them yet.

Jeff Woodard
  • 647
  • 8
  • 15
  • 3
    We will never go with code first. We have been building data driven applications for decades and we model our relational database first. We will have properties in the database that are triggered by inserts and updates to indicated change outside of the bounded contexts and even "ignored" in the application layer. Blindly saying to code first is not a solution. – hanzolo Jul 29 '19 at 20:54