A utility to fix faulty ConcurrencyMode settings

As described in the post on EFConcurrencyModeTest, the Entity Framework tools for reverse engineering a database will not set ConcurrencyMode correctly for the column types (rowversion a.k.a. timestamp) used for optimistic concurrency control. Until that bug is fixed, you have to take care if this yourself. I put up with this about twice, before getting bored enough to write a utility that automates it. To paraphrase Terence Parr (ANTLR), why edit by hand in 10 minutes what you can spend an hour automating? Thus, I wrote FixEFConcurrencyModes.

Basic usage is simple. Use the -i option to specify input file, like so

FixEFConcurrencyModes -i MyEdmxFile.edmx

This will change MyEdmxFile.edmx so that all columns of type rowversion or timestamp will have ConcurrencyMode = Fixed. If this default behaviour doesn’t suit you, there are a few options.

-i <filename>               Edmx input file. Required.
-o <filename>               Output file. Default: overwrite the input file.
-n <pattern1 pattern2 ...>  Regex patterns for column names used for concurrency control.
-t <type1 type2 ...>        Types for concurrency control. Default: rowversion timestamp
-p                          Preview. Changes are shown but nothing is written to file.
-q                          Quiet mode.
--help                      Display the help screen.

A few examples

The following will set ConcurrencyMode = Fixed on all columns of type uniqueidentifier or timestamp:

FixEFConcurrencyModes -i MyEdmxFile.edmx -t uniqueidentifier timestamp

This will set ConcurrencyMode = Fixed on all columns with names that include the substring “VersionNo” or end with “Revision”:

FixEFConcurrencyModes -i myfile.edmx -n VersionNo Revision$

If you want to preview what FixEFConcurrencyModes will change, but don’t want to save the changes, use the -p option:

FixEFConcurrencyModes -i myfile.edmx -p


Download the program here. You don’t have to install it, just copy it to wherever you like and run it from there.

The source code is available at GitHub.


  1. No comments yet.

  1. June 5th, 2015