In Razor compiler directives do not work, cause Razor Views are not compiled.
So this would not work:

@{ #if DEBUG}

@{#else}

@{#endif}

But you can trick that thing into submission, thanks to this StackOverflow topic

A better, more generic solution is to use an extension method, so all views have access to it:

public static bool IsReleaseBuild()
{
#if DEBUG
    return false;
#else
    return true;
#endif
}

You can then use it like follows in any view (razor syntax):

@if(IsReleaseBuild())

If Entity Framework (version below 5.1) on your attempt to Update-Database gives you error of “Object reference not set”, change the default start-up project to MVC project, not anything else. And try the same thing again.
This reported to be fixed in the latest 5.x version of EF, but it is a little annoyance just now.

p.s. This can be eased with parameter: -StartupProject “helloMVC” when running Update-Database command

Visual Studio Code snippets are handy way of increasing your speed of development.

User keyboard shortcuts
CTRL+K + X for code snippet
CTRL+K + S for Surround With snippet

Here are most of the described: http://msdn.microsoft.com/en-us/library/z41h7fat%28v=vs.100%29.aspx

Or you can download this Word document and print them out – the same information, only in printer-friendly view.

Snippets
Title: Snippets (0 click)
Caption:
Filename: snippets.doc
Size: 60 KB

Code-Based Migrations

Original: http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-code-based-migrations-walkthrough.aspx

Enable-Migrations
Add-Migration – scaffold next migration based on changes made to the model.
Update-Database – update database model to the latest migration model
Update-Database -Verbose – update database model and output SQL generated
Update-Database -TargetMigration: “someMigration” – update database up (or down) to a “revision”
Update-Database -Script -SourceMigration:$InitialDatabase -TargetMigration:”AddPostAbstract” Generate SQL script of the migrations
SQL(“update sometable set somefield=’hi'”) – can insert custom SQL into migration class.

Automatic Migrations

Original here: http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-automatic-migrations-walkthrough.aspx

Enable-Migrations -EnableAutomaticMigrations -Force – turn on automatic migrations

Basically does the same as code-based migrations, but before doing Database-update it automatically calls Add-Migration and gives it a name.

  • **CTR + ALT + L **- move to Solution Explorer
  • Type (for example “try” or “for”) and hit Tab twice for code snippet auto-completion.
  • Ctrl + – and the opposite Ctrl + Shift + – Move cursor back (or forwards) to the last place it was. No more scrolling back or PgUp/Dwn to find out where you were.
  • Ctrl + I – Incremental Search
  • Shift+Alt+Enter window in focus in full screen mode. Hit it again, and you have all the panels back. ****
  • Ctrl + Alt + I – jump to Immediate Window
  • Tools -> Options -> Environment -> Keyboard. Type “Navigation” to get the shortcut to combo-box on top of the window.
  • Ctrl + Shift + , or Ctrl + Shift + . to zoom-in or zoom-out
  • Ctrl + M + M – collapse/expand current region
  • Ctrl + M + O – collapse  all regions
  • Ctrl + M + L – expand  all regions
  • CTRL+K + X – code snippet
  • CTRL+K + S – Surround With code snippet More shortcuts are here:

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=13189 Or here: http://www.itscodingtime.com/post/Visual-Studio-2010-Keyboard-Mouse-Shortcuts.aspx