Thursday, August 17, 2017

Forcing Umbraco install your DB again


When you install Umbraco nuget package for the first time, it will show you a pretty installation windows and then tries to install the DB for you. What if you want to do the same when publishing your code somewhere else? What is you don't care about your site content and just want the views/ templates like for your test/staging server?

Umbraco settings

In the web config> <appSettings> of your project there is a setting that tells Umbraco which version are you on.
<add key="umbracoConfigurationStatus" value="7.6.5" />

If you remove it from the config, Umbraco has no other way than installing the DataBase again, and you will see the installation page when you try to access to the page. But wait! why doesn't it do anything?
If you take a look at the developer tools of your browser you will see that one of the requests has been failed

This is the  Error:

{"Message":"An error has occurred.","ExceptionMessage":"Invalid object name 'umbracoUser'.","ExceptionType":"System.Data.SqlClient.SqlException","StackTrace":"   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)\r\n   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)\r\n   at ....
So what is wrong?

Since we have set our connection string before, Umbraco thinks that there is a DB somewhere that has your User structure and tries to load your user. :)
Simply remove the Connection string and you will be fine 

1 comment:

  1. Montre Rolex Suisse Pas Cher, combining elegant style and cutting-edge technology, a variety of styles of Montre omega Suisse Pas Cher, the pointer walks between your exclusive taste style.