Skip to content

Resharper File Template

daniellee edited this page Apr 17, 2013 · 5 revisions

For Resharper users a File Template that can be accessed from the quick menu (Alt + Insert) can make life a bit easier. Creating migration classes for hand every time can be repetitive and a template that sets the migration attribute automatically reduces the risk of errors.

ResharperQuickMenu

A Starter Template

A starter File Template (Migration.DotSettings) for FluentMigrator migrations can be found in the docs folder. It can be tricky to find the download url for a single file from Github, so if you have downloaded the html for the github page by accident, the direct download url is https://github.com/schambers/fluentmigrator/raw/master/doc/VisualStudioTemplates/Migration.DotSettings (which is the same url as the Raw button in Github).

In the template are a couple of macros that set the namespace to the current assembly's namespace, class name to the filename and the migration attribute to the current date in yyyyMMddHHmm format.

The second Resharper DotSettings file (StandardAndAutoReversingMigrations.DotSettings) contains two File Templates, one for normal migration and one for Auto Reversing Migrations.

Importing A Template

  1. In Visual Studio click on the Resharper menu and open Templates Explorer and then open the File Templates tab. ResharperBeforeImport

  2. Click the Import button and choose the Migration.DotSettings file. ResharperSelectFile

  3. You should now see the imported Migration template under "Not in quicklist" section. ResharperNotInQuickList

  4. Drag and drop the Migration template up to the "In quicklist" section to make it available in the quicklist. ResharperInQuickList

  5. Done! Now you should be able to see Migration as an option in the Alt+Insert menu for Visual Studio's Solution Explorer.

Try it out and adjust the template to suit your own style.

Clone this wiki locally