Created
October 8, 2010 09:34
-
-
Save sovanesyan/616555 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XmlMetadataSource source = XmlMetadataSource.FromAssemblyResource("Northwind.rlinq"); | |
var model = source.GetModel(); | |
var productType = model.PersistentTypes.FirstOrDefault(x => x.Name == "Product"); | |
productType.OptimisticConcurrencyControlStrategy = OptimisticConcurrencyControlStrategy.Timestamp; | |
//Making sure there is no cached database. | |
Database.Get("NorthwindEntityDiagrams", new BackendConfiguration() { Backend = "mssql" }, model).Dispose(); | |
//initialize the database with the modified metadata | |
Database.Get("NorthwindEntityDiagrams", new BackendConfiguration() { Backend = "mssql" }, model); | |
//Now create a normal context, because there already is a cached database instance with the modified metadata, one would not be created.; | |
using (NorthwindEntityDiagrams context = new NorthwindEntityDiagrams()) | |
{ | |
Console.WriteLine(context.Categories.First().CategoryName); | |
} | |
//Disposing the database object so that the next call uses the correct metadata. | |
Database.Get("NorthwindEntityDiagrams", new BackendConfiguration() { Backend = "mssql" }, model).Dispose(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment