+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Error Deploying 4.1 Site - Database '----' already exists

Error Deploying 4.1 Site - Database '----' already exists

8 posts, 0 answered
  1. Anthony
    Anthony avatar
    15 posts
    Registered:
    03 Sep 2010
    06 May 2011
    Link to this post
    Within my development environment I successfully upgraded a Sitefinity 4.0 SP1 site to version 4.1 (4.1.1339.0) by following the installation guide.  After a few changes to my custom controls to make them compatible with the new version everything looked good and I proceeded to deploy to a new server by backing-up/restoring the database to the target database instance, publishing the site from Visual Studio and copying the file structure to the destination server, and then setting up the website on the server through IIS6 (ensuring to perform the nit-picky adjustments so the site will work in IIS6).  However, when I hit the site through a browser I'm greeted with the error Database '---' already exists. Choose a different database name.  (where --- is the name of the database defined in the DataConfig file).  I can't seem to figure out why the bootstrapper is attempting to create the database when it already exists (and is a completely valid 4.1 site database)?  Furthermore, if I change the DataConfig to point to the database within my development environment the site works!  Unfortunately for a site moving to production is not going to work for me.  What exactly am I doing wrong?
  2. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    12 May 2011
    Link to this post
    Hello Anthony,

    Sorry about the delay regarding your service request.

    Please check whether you have a database with the same name attached to you current server instance. Can you also provide the configuration settings regarding your database which is in the data.config file and some information about your sql server setup? 

    Thanks for your cooperation in advance. 

    Best wishes,
    Victor Velev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Anthony
    Anthony avatar
    15 posts
    Registered:
    03 Sep 2010
    12 May 2011
    Link to this post

    Thanks Victor, I appreciate the assistance.

    I returned to this problem this morning and had an ah-ha moment.  In migrating my newly-upgraded 4.1 website to the destination server I copied the application files to the server and then performed a restore of the database to that server, restoring on top of the existing pre-4.0 database.  What I failed to do was re-link the login, as during the restore since the SQL login already exists on that server the database's restore login becomes orphaned.

    To fix this, I ran the following SQL query against my Sitefinity 4.1 database (where 'app_sitefinity4' is the login defined in my Data.config):

    exec sp_change_users_login 'Auto_Fix', 'app_sitefinity4';

    Which gave me the expected output (note the # of orphaned users that was fixed).

    The row for user 'app_sitefinity4' will be fixed by updating its login link to a login already in existence.
    The number of orphaned users fixed by updating users was 1.
    The number of orphaned users fixed by adding new logins and then updating users was 0.

    After recycling the application pool for the website everything began to run perfectly.

    Perhaps this is a bit of unexpected functionality for the baked-in 4.1 upgrade?  (That is, the internal upgrade process when deploying the 4.1 application files that will implicitly attempt to upgrade any pre-4.1 database to the proper version)

    Steps to reproduce:
    1. On the destination server have the un-upgraded Sitefinity 4.0 site already running.
    2. From the development server/workstation take a backup of the upgraded Sitefinity 4.1 database.
    3. From the development server/workstation copy the Sitefinity 4.1 application files to the destination server, overwriting the existing files when prompted.
    4. On the destination server restore the Sitefinity 4.1 database (from step #2) over-top the existing 4.0 database.
    5. Launch a browser and hit the 4.1 site -- Will receive error Database '----' already exists.

    Resolution:
    Run sp_change_users_login with the Auto_Fix option, targeting the SQL login defined in the Data.config.
  4. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    13 May 2011
    Link to this post
    Hi Anthony,

    I am glad to hear you have managed to get your site running. Indeed this is valuable information and we will make note of that scenario and have it in our minds for future ;) I will be closing the thread for now, if you feel that you need any more assistance do not hesitate to contact me again.

    Regards,
    Victor Velev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Sebastian
    Sebastian avatar
    21 posts
    Registered:
    06 Sep 2011
    12 Apr 2012
    Link to this post
    I am getting this error going from 4.4 to 5.
    I removed the previous version 4.4 of SF database.  Created new database and restored version 5 into it.



    Server Error in '/' Application.

    Database 'db1' already exists. Choose a different database name.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Telerik.OpenAccess.RT.sql.SQLException: Database 'psmfc_sf44' already exists. Choose a different database name.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [SQLException: Database 'psmfc_sf44' already exists. Choose a different database name.]
       Telerik.OpenAccess.RT.Adonet2Generic.Impl.StatementImp.executeUpdate(String sql) +298
       Telerik.OpenAccess.RT.Adonet2Generic.Impl.StatementImp.execute(String sql) +9
       OpenAccessRuntime.DataObjects.tools.ant.DataObjectsTaskBase.ExecuteSqlScript(String script, Connection con, SqlDriver sqlDriver, Boolean noShredder) +459
    
    [OpenAccessException: SQL exception on 'CREATE DATABASE psmfc_sf44' : Database 'psmfc_sf44' already exists. Choose a different database name.]
       OpenAccessRuntime.ExceptionWrapper.Throw() +13
       OpenAccessRuntime.DataObjects.tools.ant.DataObjectsTaskBase.throwBuildException(String str, Exception e) +38
       OpenAccessRuntime.DataObjects.tools.ant.DataObjectsTaskBase.ExecuteSqlScript(String script, Connection con, SqlDriver sqlDriver, Boolean noShredder) +639
       OpenAccessRuntime.DataObjects.tools.ant.DatabaseCreationTask.createDatabase() +1819
    
    [OpenAccessException: Telerik.OpenAccess.OpenAccessException: SQL exception on 'CREATE DATABASE psmfc_sf44' : Database 'psmfc_sf44' already exists. Choose a different database name.]
       DynamicModule.ns.Wrapped_OpenAccessMetaDataProvider_92c051376af44b2b9ff8276ed51d544c.Initialize(String providerName, NameValueCollection config, Type managerType) +405
       Telerik.Sitefinity.Data.ManagerBase`1.InstantiateProvider(IDataProviderSettings providerSettings, Type providerType, ExceptionPolicyName policy, ManagerBase`1 manager) +1972
       Telerik.Sitefinity.Data.ManagerBase`1.InstantiateProvider(IDataProviderSettings providerSettings, ExceptionPolicyName policy, ManagerBase`1 manager) +74
       Telerik.Sitefinity.Data.ManagerBase`1.SetProvider(String providerName, String transactionName) +526
    
    [TargetInvocationException: Exception has been thrown by the target of an invocation.]
       System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
       System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +117
       System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +247
       System.Activator.CreateInstance() +88
       Telerik.Sitefinity.Data.ManagerBase`1.GetManager(String providerName, String transactionName) +120
       Telerik.Sitefinity.Services.SystemManager.Initialize() +232
       Telerik.Sitefinity.Abstractions.Bootstrapper.RegisterRoutes(RouteCollection routes) +307
       Telerik.Sitefinity.Abstractions.Bootstrapper.Bootstrap() +386
       Telerik.Sitefinity.Web.SitefinityHttpModule.Init(HttpApplication context) +116
       System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +575
       System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +352
       System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +407
       System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +375
    
    [HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11700992
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
       System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4869221
    
  6. Dan Sorensen
    Dan Sorensen avatar
    256 posts
    Registered:
    13 Aug 2010
    16 Apr 2012
    Link to this post
    Sebastian: Did you try Anthony's solution? I am asking because I am trying to determine if you have a different issue or problems with implementing his solution.

    I had a similar issue, and the solution was similar to Anthony's: Didn't have sufficient SQL login rights on the account listed in my data.config.
  7. Sebastian
    Sebastian avatar
    21 posts
    Registered:
    06 Sep 2011
    16 Apr 2012
    Link to this post
    Thanks for checking in Dan.  That was exactly it.  User did not have enough permissions while accessing the website. 
    It is fixed now.
  8. Mihail
    Mihail avatar
    0 posts
    Registered:
    24 Jul 2015
    15 Nov
    Link to this post

    Hi,

    I had similar problem with message "Database 'xxx' already exists. Choose a different database name." and want to share it with the community . Running Sitefinity 8.1.5800.0.  The solution was very simple. The user in the DataConfig.config file should have User Mappings for the database ('db_owner' and 'public'). This fix my problem.

     

    Open SQL Management studio, Connect > Security > Logins > find the user > Right click > Properties > User mappings > check the database and below check the roles. > OK.

8 posts, 0 answered