0

I am trying to deploy my site to 123reg but having difficulty with database permissions. I see other people have similar issues, but they all seem to be using entity framework with DBContexts, whereas I am not (I don't think).

I am using the Web.Security.Membership.CreateUser method. All of the database tables are set up. My connectionstring is almost certainly correct as I have the same setup on a different hosting provider which works perfectly. The site can read from the database but fails when it tries to write.

When the method is invoked, I get the following error.

CREATE DATABASE permission denied in database 'master'.

Is there anyway to stop the DefaultMembershipProvider from trying to create the database or tell it exactly where it is?

<add name="Simple.Data.Properties.Settings.DefaultConnectionString" connectionString="Server=ATLAS-SQL-07;Database=mydatabasename;User ID=myuserid;Password=xxxxxx;" />

I'm using Simple.Data (as can be seen the from name of the connectionstring). Maybe this is causing it problems. I don't see why it works flawlessly on my Netcetera hosting though?

To test it out further, I published the MVC4 sample web application to 123reg and pointed to the same database, it had exactly the same issue.

envio
  • 7
  • 1
  • 3

1 Answers1

1

I had a similar problem with 123-reg; and a number of other issues. I found the best approach was to blank out the call to create database and import a working database, (with one user in it). Make sure you do the import file as ANSI, otherwise you get a random character inserted on the import.

private class SimpleMembershipInitializer { public SimpleMembershipInitializer() { Database.SetInitializer(null);

            try
            {
                /*
                using (var context = new UsersContext())
                {
                    if (!context.Database.Exists())
                    {
                        // Create the SimpleMembership database without Entity Framework migration schema
                        ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
                    }
                }*/

                WebSecurity.InitializeDatabaseConnection("TobaContext", "UserProfile", "UserId", "UserName", autoCreateTables: true);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex);
            }
        }
    }

I have had a number of problems with 123-reg - some of it my fault - some of it theirs I think.

As a heads up on membership - at the moment I am getting problems with the RequireHTTPS attribute. It appears to cause a 'too many server redirects' issue. Yet I thought that attribute was suppose to work out of the box.

Good luck, hope been of some help,

Dave

David
  • 11
  • 1