@Edson_Ferreira: I have seen this error come up when your login credentials actually lack the necessary permissions in SQL Server.
This is often the consequence of installing SQL Express using a different user account from the one you are trying to use it. It has happened to me when I take a virtual machine image prepared by another person.
One way to confirm this is your case would be to open SQL Server Management Studio logging in with your regular use account and attempt to create a database manually, e.g.:
USE master;
CREATE DATABASE delete_me_next;
If you get the same error message you are getting is code first, there is your problem.
You should be able to work around this by running Visual Studio and your Code First app as an administrator every time, but this is not very safe so I would recommend that you rather grant the required permissions to your login use in SQL Server permanently.
There might be an easier way but you should be able to do the later this way:
- Starting SQL Server Management Studio as an administrator (you should now be able to create and drop databases)
- Expand the Root/Security/Logins node on the Object Explorer
- If there is an entry for your Windows account right click and open properties, otherwise create a new login for your Windows user account.
- Under Server Roles make sure there is a checkmark on a server role that has permissions to create databases, e.g. dbcreator or sysadmin.
If this is not the reason CREATE DATABASE is failing, another possibility is that the local account under which the SQL Server service is running doesn't have the necessary file system permissions to create files in the default location for new databases (i.e. under the ...\MSSQL\DATA directory).
Hope this helps.