Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the poco entity generator

I'm using VS2010, and I've download the C# POCO Entity Generator and installed it, now I want to use it.

I can't read the toturial 1 and I can't find any other good toturials, so I've had a go myself - I have created a model and then I'm creating new POCO Entity, but I got the bellow error:

Error 1 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.TextTemplatingA9DB2432A51EA8D42A615FBEB2ECB4E5.GeneratedTextTransformation.DynamicHost.ResolvePath(String path)
   at Microsoft.VisualStudio.TextTemplatingA9DB2432A51EA8D42A615FBEB2ECB4E5.GeneratedTextTransformation.MetadataLoader.TryCreateEdmItemCollection(String sourcePath, String[] referenceSchemas, EdmItemCollection& edmItemCollection)
   at Microsoft.VisualStudio.TextTemplatingA9DB2432A51EA8D42A615FBEB2ECB4E5.GeneratedTextTransformation.MetadataLoader.CreateEdmItemCollection(String sourcePath, String[] referenceSchemas)
   at Microsoft.VisualStudio.TextTemplatingA9DB2432A51EA8D42A615FBEB2ECB4E5.GeneratedTextTransformation.TransformText()
   at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result)

What is the problem? I think it can't find the model mapping, if this is the case, how do I resolve this?

1: due to internet restriction on my hometown.

like image 298
Saeed Amiri Avatar asked Oct 11 '10 13:10

Saeed Amiri


2 Answers

Check this article for error description and how to deal with it. It is problem of path substitution when creating POCO template from Add item in Visual Studio.

like image 112
Ladislav Mrnka Avatar answered Nov 19 '22 00:11

Ladislav Mrnka


This error occurs when the path to the EDMX file is incorrect in the TT file. To resolve it, open the TT file, and replace the path manually with the relative path to the EDMX file.

For example, change this:

string inputFile = @"Db.edmx";

to something like this:

string inputFile = @"..\DataAccess\Db.edmx";
like image 11
Tarzan Avatar answered Nov 18 '22 23:11

Tarzan