I checked here and the internet with no answer. How do I get this to work ? I am using discountasp.net SQ开发者_如何学运维L so is it a setting on thier side to make it work ?
The following blog post explains this well. If you haven't specified a connection string in your web.config than EF CodeFirst will attempt to create a DB on your local instance of SQLExpress. Otherwise you can set the intent by assigning to a named connnection string via the public constructor of your entities context inheriting from the base constructor.
http://blogs.msdn.com/b/adonet/archive/2011/01/27/using-dbcontext-in-ef-feature-ctp5-part-2-connections-and-models.aspx
public class UnicornsContext : DbContext
{
public UnicornsContext()
: base("UnicornsCEDatabase")
{
}
}
Either way you'll need to ensure that your account has appropriate access to the SQL(Express) server to create a new database.
User in connection string used to access database has no create database right, so the exception is thrown. Try changing user or giving him access rights.
精彩评论