Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 618867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:35:36+00:00 2026-05-13T18:35:36+00:00

I am playing around with creating a T4 template for the DDL Generation Template

  • 0

I am playing around with creating a T4 template for the “DDL Generation Template option” (model first) process in Visual Studio 2010 RC. Is it possible to retrieve the connection string that is associated with that process? If I right click on the .edmx file and choose “Generate Database from Model…” I have the option of choosing a data connection. That connection string is saved to the app.config (assuming that the option is checked). So I am wondering if it is possible to retrieve that connection string inside the T4 template. I would like to generate different information from the template based on the connection string.

More generally, is it possible to get any context information in this situation? So far, the only thing I have successfully retrieved is the .NET data provider name.

Note – I have studied the ideas provided by Craig but am only getting the name of the IDE (devenv.exe), which quite possibly means I am just doing something wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:35:37+00:00Added an answer on May 13, 2026 at 6:35 pm

    Well, the EF connection string will always have the same name as the model, right? The DB connection string will be embedded in the EF connection string. So I’d say you should be able to get it, at least indirectly, via the EF connection string.

    Because you’re not running in the assembly, have to specify the config file name.

    So it would be something like:

    var config = ConfigurationManager.OpenExeConfiguration(name);
    var cs = config.ConnectoinStrings[modelName];
    

    Note that name, here, is supposed to be an EXE name. But in the IDE, your config fine is going to be called App.config rather than MyApp.dll.config. So you may have to play around with this to get it to work — try using “App” as the EXE name!

    Worst case is open it as a file and then use the config manager.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm diving head first into ASP MVC and am playing around with creating and
I am in the process of creating a synthesiser for iOS. After playing around
I was playing around with the idea of using Visual Studio's < include >
I've been playing around with creating an e-commerce site with Codeigniter, and am trying
Just playing around with Wordpress / Contact Form 7 . Is it possible to
I just ordered an Android smartphone and want to start playing around with creating
Just playing around with Wordpress 3.0 for the first time. I've installed the Custom
I'm playing around with creating a utility class for the pimpl idiom, however I
I've been playing around with creating a new user and I keep getting this
I'm playing around with creating tiny executables under linux. My attention has come to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.