Query by viewbag

in controller: ViewBag.db = <some_query>; in view: foreach (var item in ViewBag.db) { @Html.ActionLink((string)item.table.some, “Index”, “Edit”, new { id = item.someID }, null) }

Some commands: Rollback migration

1.In Package Manager Console command Get-migrations return listing with migration names that you made: Get-Migrations 2. Update db for earlier state: Update-Database –TargetMigration: <name-from-listing-above> 3. Delete file with incorrect migration from your migrations folder in Solution Explorer. 4. Create new correct migration and update db.

Some commands: Enable Database Migrations

If you want to apply database migrations in your project just type in NuGat Console those command: enable-migrations After every change of structure in your database model need to called at migration command with your custom migration name: add-migration <name-of-change> Now it’s time to database update command: update-database and for the end – if something went […]

Some commands: Delete database in project

When we need to delete our database files and create new one. We delete file *.dbf from app_data folder in our project and tray to bulding new up we get some errors. In this case go to the windows command line (cmd.exe) and stop your SQL Local DB Serwer and delete SQL Local DB Serwer with […]