How change sql database in BC Container?

Hello.
I have BC18 Container that use standard CRONUS database. I restored one more database. And now how can I change from CRONUS to new one?

Answers

  • SanderDkSanderDk Member Posts: 497
    Have you restored the database in the SQL Express inside the container or have you restored the database on a other SQL instance?

    If you have restored the database inside the container, you can just change the database name in the service tier with powershell.

    Enter-navcontainer -containername xxxxx
    Set-NAVServerConfiguration -ServerInstance xxxxx-KeyName DatabaseName -KeyValue xxxxx
    restart-NAVServerInstance -ServerInstance xxx

    if your have restored the database outside the container the you can just recreate your container pointing to your host SQL with:
    new-navcontainer -databaseServer xxxxx
    -databaseInstance xxxxx
    -databaseName xxxxx
    -databaseCredential xxxxx
    For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.
  • PashkovskiyPashkovskiy Member Posts: 3
    SanderDk wrote: »
    Have you restored the database in the SQL Express inside the container or have you restored the database on a other SQL instance?

    If you have restored the database inside the container, you can just change the database name in the service tier with powershell.

    Enter-navcontainer -containername xxxxx
    Set-NAVServerConfiguration -ServerInstance xxxxx-KeyName DatabaseName -KeyValue xxxxx
    restart-NAVServerInstance -ServerInstance xxx

    if your have restored the database outside the container the you can just recreate your container pointing to your host SQL with:
    new-navcontainer -databaseServer xxxxx
    -databaseInstance xxxxx
    -databaseName xxxxx
    -databaseCredential xxxxx

    Thanks.
    I restored inside the container.
    For some reason powershell doesn't recognize commands Set-NAVServerConfiguration and restart-NAVServerInstance. But in the same time I can find them in the list of available commands. Strange.

    amzbo2cjoqyo.png
  • PashkovskiyPashkovskiy Member Posts: 3
    SanderDk wrote: »
    Have you restored the database in the SQL Express inside the container or have you restored the database on a other SQL instance?

    If you have restored the database inside the container, you can just change the database name in the service tier with powershell.

    Enter-navcontainer -containername xxxxx
    Set-NAVServerConfiguration -ServerInstance xxxxx-KeyName DatabaseName -KeyValue xxxxx
    restart-NAVServerInstance -ServerInstance xxx

    if your have restored the database outside the container the you can just recreate your container pointing to your host SQL with:
    new-navcontainer -databaseServer xxxxx
    -databaseInstance xxxxx
    -databaseName xxxxx
    -databaseCredential xxxxx

    I have done it, but now I can't enter the web client and I can't download symbols in VS Code.
    74p7bhltw7d2.png
    vq4aydwbyook.png
    After that I tried to create new user in shell and I got error "The tenant 'Default' is not mounted or does not exist.":
    $credentials = New-Object pscredential 'xxxx', (ConvertTo-SecureString -String 'xxxx' -AsPlainText -Force)
    New-BcContainerBcUser -Credential $credentials -assignPremiumPlan -containerName "xxxxxxxx" -PermissionSetId super -tenant xxxxx
    Any ideas?
  • SanderDkSanderDk Member Posts: 497
    Are your database you are restoring a multi tenant database?
    Per. default containers created with new-bccontainer are multitenant.
    If the database you have restored is not configured as a multitenant DB the you cannot mix the databases.
    On your new-bccontainer you can specify that the container is -multitenant:$false.

    Why are you restoring a database inside of a container? It is way faster to use the host SQL instance and your passed parameters to the container to use the DB found in the host?
    For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.
Sign In or Register to comment.