Skip to content
Visual Studio Code extension that generates a builder class from a C# model
TypeScript C# JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Travis Build Status codecov Visual Studio Marketplace Dependencies Status


C# Model to Builder Class

C# Model to Builder Class is a Visual Studio Code extension that will save you time by automatically generating a builder class from a C# model.


Stop wasting time manually writing out builder classes. Define a model and use this extension to generate your builder.


The generated file will be saved next to your model file with Builder.cs appended to the end of the original filename.

If you're not already using builders, you should start. They are a great way to easily generate data for your unit tests.

If you are using this extension and find any issues or wish to add improvements, feel free to contribute.


Here is an example of using the generated builder to create a user for a test scenario.

Start with a model that you have written.


namespace MyProject.Models
    public class User
      public string FirstName { get; set; }

      public string LastName { get; set; }

      public string Email { get; set; }

      public DateTime DateOfBirth { get; set; }

Run the extension Cmd/Ctrl + Shift + P => Generate Builder From C# Model.

Manually update the generated file to take care of any required imports and set the default values.

Import the generated file into your test class.

To create a new user with the default values defined in the builder class use the following code.

var user = new UserBuilder().build()

If you want to override the default values you can specify unique values using .With<PropertyName>(value).

var user = new UserBuilder()
  .WithDateOfBirth(new DateTime(1970, 1, 1))


To use the extension:

  • You must have a folder open in Visual Studio Code
  • You must have a model file open
  • Your model must include the text public class
  • You need to have at least one { get; set; } defined

Known Issues

  • Any required imports will have to be added manually after the builder is generated.
  • Enums will have to be added manually
You can’t perform that action at this time.