I am following the steps as outlined on MSDN Blogs > ADO.NET team blog > Walkthrough: POCO Template for the Entity Framework.
I created a simple model in the Keith.Data Project (and Namespace). I created a Keith.Model Project and added it to the solution, dropped the Class.cs file, dragged and dropped the DataEntities.tt file into the Keith.Model pro开发者_Go百科ject and added a reference to Keith.Model in my Keith.Data project. I then changed the path reference in the DataEntities.tt file from @"DataModel.edmx" to @"..\Keith.Data\DataModel.edmx". When I saved it I got this error:
Running transformation: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Unable to locate file
at Microsoft.VisualStudio.TextTemplating.VSHost.TextTemplatingService.ResolvePath(String path) at Microsoft.VisualStudio.TextTemplating.VSHost.TextTemplatingService.ResolvePath(String path) --- End of inner exception stack trace --- at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.VisualStudio.TextTemplating6A60439B68BD2BCE671B842FB15E35C4.GeneratedTextTransformation.DynamicHost.ResolvePath(String path) at Microsoft.VisualStudio.TextTemplating6A60439B68BD2BCE671B842FB15E35C4.GeneratedTextTransformation.MetadataLoader.TryCreateEdmItemCollection(String sourcePath, String[] referenceSchemas, EdmItemCollection& edmItemCollection) at Microsoft.VisualStudio.TextTemplating6A60439B68BD2BCE671B842FB15E35C4.GeneratedTextTransformation.MetadataLoader.CreateEdmItemCollection(String sourcePath, String[] referenceSchemas) at Microsoft.VisualStudio.TextTemplating6A60439B68BD2BCE671B842FB15E35C4.GeneratedTextTransformation.TransformText() at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result)
Anyone run into this and know what the problem is? I am sure I missed something but for the life of me I cannot figure out what.
TIA
I replicated the scenario you mentioned and got the same error when the Path to the .edmx file in POCO.tt (DataEntities.tt in your scenario) was wrong. Double check if the path you have specified is correct.
I use EF4/POCO but have all my entitites defined in code not an edmx so I'm not an expert in the approach you're using...
That said, a simple way to identify what the app is doing: download the sysinternals Proces Monitor and point it at VS - then have a look at what files it's trying to access (filter on DataModel.edmx). This will at least tell you where it's expecting the file to be - it's possible your relative path is incorrect.
I'm sure other devs with more experience in this topic can give you a better answer but this is how I'd approach solving it...
精彩评论