entity framework - Scaffolder unable to load EDMX metadata after upgrading to .NET4.5 and EF5 -


so i've upgraded existing mvc4 project .net4.5 , ef5. i've run project , works properly. tried run custom scaffolder, , gave me no love.

please forgive me if simple mistake, our templates written left company. i've done best understand how these work , try , debug it. after afternoon of banging head on desk, i've hit dead end...

the error message receive -

add-projectitemviatemplate : <path to>\codetemplates\scaffolders\sfrepository\repository.cs.t4(0,0) : error : running transformation:  system.invalidoperationexception: sequence contains no elements    @ system.linq.enumerable.first[tsource](ienumerable`1 source)    @ microsoft.visualstudio.texttemplatingf690eb8002d6f86a4e8ae00cfb7daa03c9eb647292d7f28842f3ee3f3550c224e18fb3ec09900009a804cdfd9776a0afb2ae2497de3d77def417124ac7de860b.genera tedtexttransformation.transformtext() @ <path to>\codetemplates\scaffolders\sfrepository\sfrepository.ps1:39 char:1 + add-projectitemviatemplate $outputpath -template repository -model @{ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + categoryinfo          : notspecified: (:) [add-projectitemviatemplate], exception     + fullyqualifiederrorid : t4scaffolding.cmdlets.addprojectitemviatemplatecmdlet 

so looked @ t4 template itself. process of elimination, have found error happen on line -

var entity = itemcollection.getitems<entitytype>().where(e => e.name == model.entityname).first(); 

here's full copy of template point -

<#@ template language="c#" hostspecific="true"  inherits="dynamictransform" #> <#@ include file="ef.utility.cs.ttinclude"#> <#@ assembly name="system.data.entity" #> <#@ import namespace="system.linq" #> <#@ import namespace="envdte" #> <#@ output extension="cs" #> <#@ import namespace="system.collections" #> <#@ import namespace="system.collections.generic" #> <#@ import namespace="system.linq" #> <#@ import namespace="system.text.regularexpressions" #> <#@ import namespace="envdte" #> <#@ assembly name="system.componentmodel.dataannotations" #> <#@ assembly name="system.core" #> <#@ assembly name="system.data.entity" #> <#@ assembly name="system.data.linq" #> <#@ import namespace="system" #> <#@ import namespace="system.componentmodel.dataannotations" #> <#@ import namespace="system.data.linq.mapping" #> <#@ import namespace="system.data.objects.dataclasses" #> <#@ import namespace="system.reflection" #> using system; using system.collections.generic; using system.data; using system.data.entity; using system.linq; using system.linq.expressions; using system.web; using omu.valueinjecter; <# foreach(var ns in new[] { model.modeltypenamespace, model.dbcontextnamespace }.where(x => !string.isnullorempty(x) && (x != model.repositorynamespace)).distinct()) { #> using <#= ns #>; <# } #> using <#=model.project#>.dataobjects;  namespace <#=model.project#>.models {  <#      var modeltype = (codetype)model.modeltype;      var modelname = modeltype.name;      var modelnameplural = model.modeltypepluralized;      var primarykeyproperty = modeltype.visiblemembers().oftype<codeproperty>().single(x => x.name == model.primarykey);      codegenerationtools code = new codegenerationtools(this);     metadataloader loader = new metadataloader(this);     coderegion region = new coderegion(this, 1);     metadatatools ef = new metadatatools(this);      // create our item collection specified edmx     edmitemcollection itemcollection = loader.createedmitemcollection(model.inputfilename);      // find our entity pool     var entity = itemcollection.getitems<entitytype>().where(e => e.name == model.entityname).first(); 

i tried taking out, , pulling first item. there still no items in collection.

best can tell, metadataloader in ef.utility.cs.ttinclude isn't able read ef5 edmx reason.

i noticed local copy of ef.utility.cs.ttinclude wasn't recent 1 under "c:\program files (x86)\microsoft visual studio 11.0\common7\ide\extensions\microsoft\entity framework tools\templates\includes" tried copying local project. unfortunately there no change.

i verified model.inputfilename holding correct path edmx file.

so question is... why? there else need update scaffolders ef5 , .net4.5? haven't seen common issues posted elsewhere this...

on day 2 of adventure began converting ef.utility.cs.ttinclude c# console app see if couldn't glean better error message.

i noticed constants @ bottom of file didn't include newer ef5 namespaces.

i compared copy 1 under "c:\program files (x86)\microsoft visual studio 11.0\common7\ide\extensions\microsoft\entity framework tools\templates\includes" , sure enough, mine out of date.

during debugging, know updated (as mentioned above). either copied wrong folder, or i'm losing mind. either @ point.

either way, solution update local copy of ef.utility.cs.ttinclude 1 under "c:\program files (x86)\microsoft visual studio 11.0\common7\ide\extensions\microsoft\entity framework tools\templates\includes" , works perfectly.

thanks took time read question!


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -