I have created a .NET backend for a Xamarin iOS app using the Azure portal following this tutorial from Microsoft : tutorial
I then used an existing database, with this new backend. When I try to log into my mobile app however, the log in fails with the above error:
There is already an object named in the database
The existing database was under a different subscription which will be deactivated. I imported it into the new subscription and set it up.
I have seen tons of similar questions here and have tried some solutions too. I still have the error.
Since I changed the namespace in the new backend,I have read this from an answer here on StackOverflow:
There is a table in your data base called dbo.__MigrationHistory. The table has a column called ContextKey. The value of this column is based on your namespace. for example is "DataAccess.Migrations.Configuration". When you change the namespace, it causes duplicate table names with different namespaces. So, after you change namespace in code side, change the namespace in this table in database, too, (for all rows).
I suspect that this might be an issue in my case, but I am currently unable to access my database.
I have also tried this solution which hasn't worked :
Database.SetInitializer<YourContext>(null);
And lastly, I have tried to use the update-database
command in the Package Console Extension i Xamarin Studio but I get the error
:
command update-databse not found
I'm now not sure how to resolve this issue. Could someone point me in the right direction?
Thanks.
EDIT
Based on the explanation above regarding changing the context,I already updated this in the Configuration.cs
class as below:
internal sealed class Configuration : DbMigrationsConfiguration<testService.Models.testserviceContext> // new namespace changed here
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
AutomaticMigrationDataLossAllowed = true;
SetSqlGenerator("System.Data.SqlClient", new EntityTableSqlGenerator());
}
}
So does this update the dbo.__MigrationHistory
table or do I still need to run an update command?