Praveen VR
Praveen VR

Reputation: 1564

Dynamically create edmx entities using T4

I have a situation to create (visible true/false) some entities(Tables) in edmx file depends upon some table row values using T4 template in C#. how can I do this?

Edit: I have created edmx file with entities and added a texttemplate.tt file with some code to generate edmx entities.While saving the file, the entities generated successfully in .cs file of texttemplate

Please help.

Upvotes: 0

Views: 509

Answers (1)

Believe2014
Believe2014

Reputation: 3964

I had a similar situation where my database is huge and I just want to be able to generate entity classes for a group of tables. Unfortunately, you'll have to deal with a lot of things if you want to manipulate the EDMX file in XML language. Otherwise, you could customize the .tt files to skip generating classes for certain names.

Entity Interface Generator https://entityinterfacegenerator.codeplex.com

Version 1.2 of this project contains customized T4 templates which can conditionally generate interfaces for entity classes and interfaces matching by regular expressions.

You can learn to do similar name matching by comparing the customized .tt files with the original from Microsoft.

Upvotes: 1

Related Questions