Gil
Gil

Reputation: 1123

EF5 Starting a Project:Error Running transformation: Please overwrite the replacement token '$edmxInputFile$'

I'm creating a Console Project in VS2012 with .Net4.5. After it I "Add", "New Item" to the project, and choose "EF 5.x DbContext Generator". Then, after a couple of seconds the following error message appears in the 'Error List' tab:

Error 1 Running transformation: Please overwrite the replacement token '$edmxInputFile$' with the actual name of the .edmx file you would like to generate from. C:\Projects\Tests\ConsoleAppEF5\ConsoleAppEF5\Model1.tt`

How can I fix this ?

What am I missing ?

Upvotes: 44

Views: 37392

Answers (4)

workabyte
workabyte

Reputation: 3775

In my case I was inadvertently adding the EF Db Context Generator instead of Entity Framework. Total PEBKAC but I'm posting it here as I'm sure I will not be the only one.

I noticed that the file extension was TT as this is a text template not the EDMX that I wanted.

If you are looking to add entity then add ADO.NET Entity Data Model not EF X.x DbContext Generator

Upvotes: 12

vapcguy
vapcguy

Reputation: 7544

In my case, I decided I wanted to get rid of the EF 5.x DbContext Generator. I got this error when I selected to add it, but then deleted "Model1.Context.tt" and "Model1.tt" after thinking better of it. Unfortunately for me, I didn't realize that's not all I had to do. When I did another "Build", I got the OP's error.

My next steps: I went to Model1.tt, cleared out $edmxInputFile$ and left it as an empty string and clicked to build the project. This gave me an UnauthorizedException error (which is fine, I didn't want it modifying anything, anyway). I just wanted it to get rid of the original error.

Next, I did some poking around and I found out that my project's ".csproj" file was modified with this:

<ItemGroup>
    <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>

Now I don't think this GUID is going to be the same in all cases of the error, or even everytime anyone adds on the EF 5.x DbContext Generator. But if your .csproj file (NOTE: this is different than your .csproj.user file) has been changed (hopefully it's in source control and you can tell this), you should be able to figure out how. I deleted this section, did a "Build", and got rid of my errors.

If it's not in source control, you can always create a dummy project and compare your .csproj file to that project's file, and do some trial and error by taking out anything that is extra on your .csproj and doing a "Build" (saving things to Notepad, putting them back if it doesn't clear your error). I know this is a helluva way to do it, but at least you won't waste time redoing your entire solution.

Upvotes: 2

Alex
Alex

Reputation: 14523

And in another scenario, this is apparently a known bug: http://web.archive.org/web/20131203074519/http://connect.microsoft.com/VisualStudio/feedback/details/498723/ado-net-entityobject-generator-error-list-bug

So if you add a DbContext Generator and then remove it and you get this error, just close and reopen the project. Solved it for me.

Upvotes: 47

eternity
eternity

Reputation: 1728

You should create edmx model first to generate POCO's from it automatically. You can add it through menu (Add New Item -> ADO.NET Entity Data Model). After the model will be created you can use the DbContext generator. Replace $edmxInputFile$ with the name of your edmx file and then save file you are edit (though VS 2012 should do it automatically).

Upvotes: 52

Related Questions