Search code examples
entity-frameworkasp.net-mvc-4db-first

DB First, MVC 4, CREATE DATABASE permission denied in database 'master'


I keep getting this error on my server when I publish my site - even without changes in database model.

The site is running fine local.

I'm using the DB first approach.

If I delete all files in the site on the server, restore my local database on the server. Publish the site from VS. Sometime it will run fine after that.

If I then make a few changes in the database CONTENT I will get the error.

I don't whant to create any database/tables on the server - just disable the part of the code, that need to do it. In MVC3 we had this DropCreateDatabaseIfModelChanges but I can't see any of that in my current site.

What can I do?

My connectionstring:

    <connectionStrings>
     <add name="GoBagHomeComEntities"     connectionString="metadata=res://*/Models.GoBagHomeModel.csdl|res://*/Models.GoBagHomeModel.ssdl|res://*/Models.GoBagHomeModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\sqlexpress;initial catalog=GoBagHomeCom;Persist Security Info=True;User ID=xx;Password=xxxx;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"
      xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
     </connectionStrings>

And my dbcontext

public partial class GoBagHomeComEntities : DbContext
{
    public GoBagHomeComEntities()
        : base("name=GoBagHomeComEntities")
    {
    }

Solution

  • It seems like the problem is solved :)

    I'm sure Owin was the bad guy - I was only using it for creating the authentication cookie. Nothing about tables.

    After remove all Owin related code on the site it's running.