Entity Framework 6 Transaction

using (var dbContextTransaction = dbContext.Database.BeginTransaction())
var job = new Job{Name = "Name"}

var companyJobs = new CompanyJob{Name="Name",JobId = Job.Id};
catch (Exception)

Another method is using scope, pass TransactionScopeAsyncFlowOption.Enabled to TransactionScope() constructor to allow async saving method

using (var transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
var job = new Job{Name = "Name"}

var category = dbContext.Categories.Find(2);


More ways here

Dealing with One-to-Many Relationship in Fluent API

For example, a Company has many Jobs, in Company Configuration add
HasMany(c => c.Jobs)
.WithRequired(j => j.Company)
.HasForeignKey(j => j.CompanyId);

Without the above configuration, Company navigation property of Job will not work.

While in Job Configuration
HasRequired(j => j.Company)
.WithMany(c => c.Jobs)
.HasForeignKey(j => j.CompanyId);

Add the 2 configuration so that their navigational properties will work.

Adding Glimpse to ASP.Net

Glipse is a tool to monitor the performance of web app.

install-package glimpse.mvc5
Install-Package Glimpse.EF5

If you encounter this problem
Unable to cast object of type 'Glimpse.Ado.AlternateType.GlimpseDbConnection' to type 'System.Data.SqlClient.SqlConnection'.
Uninstall Glimpse.EF5 and install
Install-Package Glimpse.EF6
You can view Glimpse endpoint in /glimpse.axd

Could Not Find Driver in Ubuntu CLI

Note, the PHP version of Apache and Terminal could be different.
Web phpinfo() shows

Loaded Configuration File /etc/php5/apache2/php.ini
PDO drivers | mysql, sqlite

Checking on the terminal

$ php -i |grep php\.ini
Configuration File (php.ini) Path => /etc/php/5.6/cli
Loaded Configuration File => /etc/php/5.6/cli/php.ini

Checking for drivers
$ php -i|grep PDO
PDO support => enabled
PDO drivers =>

As we see we have no drivers

Ubuntu 14.04.3 LTS
sudo apt-get update
sudo apt-get install php5.6-fpm php5.6-mysql
$ php -i|grep PDO
PDO support => enabled
PDO drivers => mysql
PDO Driver for MySQL => enabled

Installing PHP 7 with Ubuntu

To fix “Could Not Find Driver” error
Ubuntu 16.04.1 LTS
sudo apt-get update;
sudo apt-get install php7.0-fpm php7.0-mysql

Ubuntu: Restrict Access to PHPMyAdmin

Add this directives if you want to allow only to view your phpmyadmin
Order Deny,Allow
Deny from All
Allow from


<Directory /usr/share/phpmyadmin>
        Options FollowSymLinks
        DirectoryIndex index.php
        #allow access to specific IP
        Order Deny,Allow
        Deny from All
        Allow from

        <IfModule mod_php5.c>
                AddType application/x-httpd-php .php

                php_flag magic_quotes_gpc Off
                php_flag track_vars On
                php_flag register_globals Off
                php_admin_flag allow_url_fopen Off
                php_value include_path .
                php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
                php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/javascript/


then restart apache
sudo service apache2 restart

tsc.exe exited with code 1

Visual Studio 2015 build error after adding typscripts
tsc.exe exited with code 1
Open project ____.csproj in text editor and remove 2.0
you can search for TypeScriptToolsVersion

Also since I was practicing typescript that time, I also removed all .ts to clean my project.

Asp.net Web API 2

1. Create new folder.
2. Right click on the newly created folder, select Add > Controller > Web API 2 Controller – Empty

A readme.txt will open containing the instruction.

Visual Studio has added the full set of dependencies for ASP.NET Web API 2 to project .

The Global.asax.cs file in the project may require additional changes to enable ASP.NET Web API.

1. Add the following namespace references:

using System.Web.Http;
using System.Web.Routing;

2. If the code does not already define an Application_Start method, add the following method:

protected void Application_Start()

3. Add the following lines to the beginning of the Application_Start method:


Protecting WordPress Login

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

# Stop Apache from serving .ht* files
<Files ~ "^\.ht">
Order allow,deny
Deny from all

# Protect wp-login
<Files wp-login.php>
AuthUserFile ~/.htpasswd
AuthName "Private access"
AuthType Basic
AuthUserFile /absolute-path-to-htpsswd/.htpasswd
Require valid-user



-One of Googles top criteria for ranking pages
-Quality over quantity
–small number of backlinks from quality sites are better than more but from spammy sites
-Check you competitors links including total count, quality and sources

Facebook Page Promotion

The estimated likes per day can greatly vary as reported. One marketing I had on a local city initially reports only 2 ~ 9 likes per day but on actual it yields to 27 for the first 8 hours of the campaign. So just launch the campaign and observe.

There are many factors the affects the yield of your campaign, make sure it is visually appealing, interesting, suggests something to do and always know your clients first to yield better results.