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.
Getting error “Asp.net 4.0 has not been registered on the web server.. blah-blah”?
Run this command as Administrator:
This will register ASP with IIS.
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.
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.
set the form’s KeyPreview property to true, and add this override to the Form code:
protected override void OnKeyDown(KeyEventArgs e)
if (e.KeyCode == Keys.Escape)
- **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