The DataContextEntityObjects.cs file is automatically created from DataContextEntityObjects.tt and uses the attribute in various places, such as
[EdmFunction("DataContext", "Split")] public IQueryable<Split_Result> Split(global::System.String rowData, global::System.String splitOn) {
Since it is updated automatically every time the model is updated through updating the model from the database , the solution was to change the T4 template as follows:
I have identified the relevant part in the T4 file starting here (lines 214-283):
//////// //////// Write EntityContainer and ObjectContext Function Import methods. //////// region.Begin(CodeGenerationTools.GetResourceString("Template_RegionFunctionImports")); foreach (EdmFunction edmFunction in container.FunctionImports) { IEnumerable<FunctionImportParameter> parameters = FunctionImportParameter.Create(edmFunction.Parameters, code, ef);
As indicated in the Practical Guide template . Setting up code generation at the object level and artifact generation using text templates , the template can be changed to create the correct code.
Do the following:
- Open the
DataContextEntityObjects.tt file Find and replace the following:

Save the DataContextEntityObjects.tt file
From this moment, every time you update the model, it generates the corresponding * .cs file, correctly creates the attribute inside, and therefore the outdated warning disappears.
Matt Mar 18 '15 at 10:16 2015-03-18 10:16
source share