Connection String
In web project it may be not obvious why is database not created. The error message may tell about the null reference exception, but not about the actual one. Make sure that a user with which you’re connecting to the database has appropriate access. It may have no access if you use a default user with integrated security. In IIS 7.5 default user IIS APPPOOL\DefaultAppPool (a member of IIS_IUSRS group). The best practice here is to create a special user to login to the database and do not use integrated security.
The database is not created
Check whether a DB user is in server role dbcreator
See also
- Starting point: http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx
- Code First migration: http://msdn.microsoft.com/en-US/data/jj591621