This project is read-only.

Using in Run-Time

Apr 8, 2010 at 7:04 AM


First, I explain my requirement in a big dynamic database-oriented application: I need to generate EF model in run-time from a database by passing a database name/connection string in addition to candidate table names and getting the generated code or entity objects.

First, did anybody implement a solution for this before?

Secondly, My solutions/workarounds :

1. I combine the T4 Toolbox EF generator (which generate a EF model from .mdf database file/connectionstring) with TC.CustomTemplating for parameter enabling the T4 Toolbox that I able to pass the database name or connection string to T4 template nad generating the model, What a great sound, but unfortunately, it did not work as expected and facing error due to exception message [Directive processor T4Toolbox.DteProcessor not supported!], then what should I do to correcting/workarounding this problem and getting the result ?

2. Second solution way using preprocessed templates in VS2010 and plasing the EF generator template in a preprocessed template and define a property to provide the database name in partial class and consequently instanciating the generated preprocessed template class the call TransformText(), but there was 2 problem, first preprocessed template failed in generating underlying class and I do not know why, I think it related to T4 Toolbox. Finally, how can get output generated text/code from template which is called from TransformText() method ?

Any help would be grately appreciated.

Apr 12, 2010 at 1:17 AM

Current version of T4 Toolbox requires Visual Studio and will not work under TextTransform or a custom host at run time. I think you are on the right track with option #2 as long as you use the plain T4 templates for EF.


Apr 12, 2010 at 5:56 AM

Thank you Oleg

What do you mean by plain T4 templates for EF?, Do you mean the T4 template which is embeded in VS2010 ?,If so, it generates from an EDMX file or am I wrong ?, Hense, how can do parametrization on this template for generating the model from a connectionstring/database name ?