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 6578933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:50:05+00:00 2026-05-25T15:50:05+00:00

I am looking to use MvcScaffolding for a website that I already have a

  • 0

I am looking to use MvcScaffolding for a website that I already have a database for.

I am using the repository switch when scaffolding to create a repository per entity and then editing the file to use the entities rather than the MvcScaffolding context, obviously if I re generate the files then this change will be overwritten and I will have to fix all 80+ repositories!

So I have created a custom repository template using

Scaffold CustomTemplate repository repository

which I am looking to edit so that the repositories are generated correctly. I know I need to edit this line

<#= contextName #> context = new <#= contextName #>();

but I can’t find which variable I should replace contextName with.

I know I could easily hard code the model name in the repository file which I am about to do but wondered if there is a better way to do this?

The reason for wanting a way to do it programmatically is for scenarios where more than 1 EF model is used in a project and scaffolding is used for both.

Thanks

OneShot

  • 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-25T15:50:05+00:00Added an answer on May 25, 2026 at 3:50 pm

    There’s a DbContextType param for the scaffolders –

    -DbContextType : Specify the name of the database context class that
    should be generated or updated. By default, we use the name
    Context, e.g., SoccerSiteContext.

    Could you set that to be the name of the relevant model and avoid changing the template?

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

Sidebar

Related Questions

I am looking to use a database project in visual studio 2010 so that
I am looking to use Entity framework as database layer in my application, but
I'm looking to use SELECT LAST_INSERT_ID() Am using a form to have a user
I am looking to use jquery to search for a certain string that gets
I am looking to use the map file to resolve addresses that I get
I am writing a WP7 app and looking to use the Microsoft CE database
I am looking to use FTP to write a mainframe jobstream. To do that,
I am looking to use CKEditor in ASP MVC application. I have been having
I'm looking to use the UpdateModel method to a Sub Class that retrieved at
Im looking to use MVCMailer to send emails using asp.net mvc 3 with razor.

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.