Solved

On the deployed site I get the following error message CREATE DATABASE permission denied in database 'master'.

Posted on 2016-08-22
7
139 Views
Last Modified: 2016-08-27
On the deployed site I get the following error message "CREATE DATABASE permission denied in database 'master'." when the db already exists. I can connect to the database with no problem from MS SQL Server Management Suite but when the web application tries to access the database I get the above error. I use the same login credential from MS SQL MS as from the app. Hosted on godaddy. My connection strings are:
<connectionStrings>
    <add name="csCommunityCrier" connectionString="Data Source=198.71.225.113;Initial Catalog=dbCommunityCrier.mdf;Integrated Security=False;User ID=*******;Password=*******;Connect Timeout=15" providerName="System.Data.SqlClient" />
    <add name="CommunityCrierEntities" connectionString="metadata=res://*/App_Code.CommunityCrierModel.csdl|res://*/App_Code.CommunityCrierModel.ssdl|res://*/App_Code.CommunityCrierModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=198.71.225.113;Initial Catalog=dbCommunityCrier.mdf;Integrated Security=False;User ID=**********;Password=********!;Connect Timeout=15;MultipleActiveResultSets=TrueApp=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>

Open in new window

0
Comment
Question by:OhioWoodWright
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 41765718
The issue is not with your connection string but with what you are trying to do with it.  Somewhere you are issuing a CREATE DATABASE command for a database that already exists.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41765734
First: as already mentioned - please read the error message you get and then think about it, not assume the problem is something totally different.

Second: On the deployed site....  Does that mean it works perfectly on your development machine?
0
 

Author Comment

by:OhioWoodWright
ID: 41765735
No place in my code am I issuing a CREATE DATABASE command. Ive done a global search and the stack trace is pointing to EF maybe?

Stack Trace:
[SqlException (0x80131904): CREATE DATABASE permission denied in database 'master'.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +2441746
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5736520
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +628
   System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +3731
   System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) +940
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +272
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +280
   System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<NonQuery>b__0(DbCommand t, DbCommandInterceptionContext`1 c) +10
   System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) +72
   System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext) +356
   System.Data.Entity.SqlServer.<>c__DisplayClass1a.<CreateDatabaseFromScript>b__19(DbConnection conn) +119
   System.Data.Entity.SqlServer.<>c__DisplayClass33.<UsingConnection>b__32() +443
   System.Data.Entity.SqlServer.<>c__DisplayClass1.<Execute>b__0() +10
   System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func`1 operation) +189
   System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation) +78
   System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection, Action`1 act) +175
   System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action`1 act) +557
   System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(Nullable`1 commandTimeout, DbConnection sqlConnection, String createDatabaseScript) +86
   System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection) +164
   System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection) +76
   System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase() +134
   System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection connection) +119
   System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) +142
   System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +78
   System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext internalContext, Func`3 createMigrator, ObjectContext objectContext) +89
   System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext objectContext, DatabaseExistenceState existenceState) +116
   System.Data.Entity.Database.Create(DatabaseExistenceState existenceState) +218
   System.Web.Providers.ModelHelper.EnsureDatabaseCreated(DbContext db) +80
   System.Web.Providers.ModelHelper.CreateMembershipContext(ConnectionStringSettings setting) +86
   System.Web.Providers.DefaultMembershipProvider.ValidateUser(String username, String password) +99
   System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +59
   System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +113
   System.Web.UI.WebControls.Login.AttemptLogin() +119
   System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +75
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +114
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +164
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3562

Open in new window

0
CHALLENGE LAB: Troubleshooting Connectivity Issues

Goal: Fix the connectivity issue in the lab's AWS environment so that you can SSH into the provided EC2 instance.  

 

Author Comment

by:OhioWoodWright
ID: 41765737
Yes it works perfectly on my site
0
 
LVL 34

Assisted Solution

by:Brian Crowe
Brian Crowe earned 500 total points
ID: 41765746
Apparently I was wrong.  It may in fact be a connectionstring issue related to Entity Framework.

I found the following reference which hopefully will help...

According to this question, it may be an issue related to the class name and database name not matching, which would cause EF to try to create a new database.

http://stackoverflow.com/questions/28492201/ef-code-first-create-database-permission-denied-in-database-master-error
0
 

Accepted Solution

by:
OhioWoodWright earned 0 total points
ID: 41765758
Got it. It was a hard to catch boneheaded error in the connection string. I left the file extension on the db name. Works fine now. Thanks for you help, may have taken me more hours of research for a stupid typo.
0
 

Author Closing Comment

by:OhioWoodWright
ID: 41772833
was my mistake - typo
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question