How to add EntityObject Generator in Visual Studio 2015?

I installed the latest version of Entity Framework (EntityFramework.6.1.3) in VS2015. I added EF to the project and deleted 2 .tt files (edmx_file_name.tt and edmx_file_name.Context.tt) as they were from DBContext.

Now I'm trying to add an EF 6.x code generation template by opening the model in EF Designer, right-click on the design surface and select Add Code Generation Element.

To add code generation to ObjectContext, I need to install EF 6.x EntityObject Generator. I downloaded it from here .

But I could not install it in VS 2015.

How to solve this?

+5
source share
2 answers

Since EntityObject template template is still not supported in Visual Studio 2015, an alternative solution, open your solution using Visual Studio 2013, then open the edmx diagram, right-click, select "Add code generation element", you see "Generator EntityObject Generator EF 6.X ", if you do not see it, go to the" online "menu and you will see" EF 6.x EntityObject Generator For C # ". Select the EntityObject generator and click the Add button to add it to the data access tier project. Tt automatically generates EntityObject classes for you. Save the project, exit visual studio 2013. Reopen the solution using visual studio 2015. Done.

+1
source

Well, for all those poor souls like me who no longer have VS2013, it's much easier. You can simply install the EF 6.x EntityObject Generator for C # for VS2015.

Of course, VSIX will yell at you that it is not intended for 2015. Just ignore it :)

The fact that it is not supported or advertised as "compatible with VS2015" does not mean that it does not work. This is a T4 template pack. Since then, their syntax or functions have not changed much.

Download VSIX from the market, save it somewhere, unzip it (this is only a ZIP archive), and then edit the file with the name: extension.vsixmanifest . Inside you will find such a block:

<SupportedProducts> <VisualStudio Version="10.0"> <Edition>VCSExpress</Edition> <Edition>VWDExpress</Edition> <Edition>Pro</Edition> </VisualStudio> <VisualStudio Version="11.0"> <Edition>VCSExpress</Edition> <Edition>VWDExpress</Edition> <Edition>Pro</Edition> </VisualStudio> <VisualStudio Version="12.0"> <Edition>VCSExpress</Edition> <Edition>VWDExpress</Edition> <Edition>Pro</Edition> </VisualStudio> </SupportedProducts> 

Copy, paste, add a block for Version="13.0" and possibly also (14.0 = VS2017?), Save, write it back, change the extension to .vsix and try installing.

It worked for me on VS2015, without any problems, added EntityObject T4 templates and generated code from EDMX, as expected.

+2
source

All Articles