1. Overview
  2. Examples
  3. Updating a Scaffolded DbContext Class

Updating a Scaffolded DbContext Class

It is possible that the DbContext class created when Entity Framework scaffolded your database ( See Import) is missing some namespaces, has the wrong namespace, or lacks a particular type of constructor.

In this next scenario, the EF Scaffolder generated the DbContext Class - MyProjectContext.cs with the same namespace for the model classes.

However, the DbContext class is supposed to be located elsewhere, which automatically requires it to have a different namespace, which will be MyProject.Data. Hence, we will need to configure CodeStencil to replace this namespace so that we have the result shown below:

 


Was this article helpful?