I started to use Entity Framework 6.0.1 version. I want to separate the generated DbContext and POCO template classes to different class library from the model. I spent a few hours solve the problem without any success.
If I create a new class library, add EF 6 EntityObject Generator and fill the following template variable:
SourceCsdlPath = @"..\..\DataAccess\Model.edmx"
,
Get the following error in the error list after building:
Error 2 Running transformation: System.IO.FileNotFoundException: Unable to locate file File name: 'C:\Source\EFsource\POCO....\DataAccess\SZOSZRDBModel.edmx'
Server stack trace: at Microsoft.VisualStudio.TextTemplating.VSHost.TextTemplatingService.ResolvePath(String path) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost.ResolvePath(String path) at Microsoft.VisualStudio.TextTemplating31479401930D2C4820ACF71C66B5389A24A5053726798D9718DB676B3FFA30A3454B3CB1EDE2E1C267D5278B1528860C072E81A0E4647BC23993669604048FCD.GeneratedTextTransformation.ApplyUserSettings(UserSettings userSettings) at Microsoft.VisualStudio.TextTemplating31479401930D2C4820ACF71C66B5389A24A5053726798D9718DB676B3FFA30A3454B3CB1EDE2E1C267D5278B1528860C072E81A0E4647BC23993669604048FCD.GeneratedTextTransformation.TransformText()
The Error message is clear, but i do not know, how to set Model path without full absolute path.
I am not sure, using newest version of entity framework is the best idea...
Absolute paths are not required. It looks like your relative path is not correct. I am using EF6.1 and I have the POCO classes in a separate project. This is how I got it to work in VS 2013.
ADO.NET Entity Data Model
. This project will contain the DB Context
.EF6.x DbContext Generator
item to the DBContext
project.POCO
objects.[Project Name]Model.tt
file from the DbContext
project to the POCO
project.[Project Name]Model.tt
file. On line 5, I changed:const string inputFile = @"SampleModel.edmx";
const string inputFile = @"..\DbContext\SampleModel.edmx";
DbContext
project to the POCO
project.If you are using VS 2013, you can debug the template to see how your relative path is being resolved.
.tt
file..tt
file in the Solution Explorer and select "Debug T4 Template".If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With