EF defaults to no concurrency control (last write wins) which allows lost updates. Enforcing optimistic concurrency checks can explicitly be configured by setting Concurrenc
Seems like this Feature is not going to be around for EF 5 or EF 6.
I whipped up a quick console app to update the edmx after generating DB First.
Just drop the file in the same directory of your edmx file and run after every regeneration.
Will work for any of the following columns:
RowVersion timestamp NOT NULL
rowversion timestamp NOT NULL
RowVer timestamp NOT NULL
rowver timestamp NOT NULL
You can get the console app here https://dl.dropbox.com/u/3576345/EFConcurrencyFixed.exe
or use this piece of code in your own console app.
class Program
{
static Dictionary replacements = new Dictionary()
{
{ " ",
" "},
{ " ",
" "},
{ " ",
" "},
{ " ",
" "},
};
static void Main(string[] args)
{
// find all .edmx
string directoryPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
foreach (var file in Directory.GetFiles(directoryPath))
{
// only edmx
if (!file.EndsWith(".edmx"))
continue;
// read file
var fileContents = System.IO.File.ReadAllText(file);
// replace lines
foreach (var item in replacements)
fileContents = fileContents.Replace(item.Key, item.Value);
// overwite file
System.IO.File.WriteAllText(file, fileContents);
}
}
}