Getting Started in Visual Studio

  1. Ensure that you have the NuGet Package Manager installed.
  2. Install the NDBGen Visual Studio Templates
  3. Create a new class library project.
  4. Using NuGet, add the NDBGen package.
  5. From the Add -> New Item dialog in Visual Studio, add an NDBGen Configuration File. This should automatically be named ndbgen.config.
  6. Add the following Pre-build event command line to your project, including the quotes: "$(SolutionDir)packages\NDBGen.\lib\net40\ndbgen.exe" -config "$(ProjectDir)ndbgen.config"

Adding schema markup, a data access generator and SQL script generator

  1. Add a text file named Schema.dbgs. This is where you will start adding the schema markup.
  2. Using NuGet, add NDBGen generator packages for LINQ-to-SQL and SQL Server (search for NDBGen).
  3. Add references to System.Data.Linq and System.ComponentModel.DataAnnotations to your project.
  4. In ndbgen.config, uncomment the <ndbgen>/<output>/<schema>/<dataAccess>/<add generator="LinqToSql"> element and its children.
  5. In ndbgen.config, uncomment the <ndbgen>/<output>/<schema>/<database> element and its children.
  6. In ndbgen.config, find and replace "MyProject.csproj" with the name of your project file.

Adding data markup and script generators

  1. Add two text files, one named LookupData.dbgd, the other named SeedData.dbgd.
    • LookupData should contain data like enums and other dictionary-style tables; SeedData should contain other data, such as default configurations, required for the initial functionality of your application.
  2. In ndbgen.config, uncomment the <ndbgen>/<input>/<data> element and its children.
  3. In ndbgen.config, uncomment the <ndbgen>/<output>/<data> element and its children.

I'd like to apologize for the number of steps currently involved in this process. I hope to streamline this as much as possible as the tooling for NuGet and my understanding of extending Visual Studio evolves. Thanks for sticking with it, and I hope you enjoy using NDBGen!


Last edited Aug 4, 2011 at 4:38 PM by DanielSchaffer, version 13


No comments yet.