1
votes

I'm moving my project from one machine to another. I simply zipped the project folder and moved it to my new computer. My project is an asp.net mvc application with Entity Framework. I have my connection string in my web.config file. When I run my application on my new machine, it has trouble connecting to the database it seems.

I get this error when trying to create a dbcontext

[SqlException (0x80131904): There is already an object named 'Merchandises' in the database.]

But the odd thing is it runs perfectly fine on my old machine.

I executed add-migration command and it says I'm very behind in migrations but this is not true.

Unable to generate an explicit migration because the following explicit migrations are pending: [201802070210548_Initial_Migration, 201802130149472_Added_TrackForm, 201802181945057_Added_DOB]. Apply the pending explicit migrations before attempting to generate a new explicit migration.

Any assistance for debugging this would be greatly appreciated.

1
Does the connection string point to a local DB on each dev machine, or the same DB on a third machine? - Jonas Høgh
Hi, the connection string does not point to a local db. Sorry I should have stated that. They both connect to a server. Exact same details <add name="DefaultConnection" connectionString="Server=xxx.168.194.xxx;Database=xxx;User ID=xxx;Password=xxx!;Persist Security Info=True;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" /> - Master
Have you tried inspecting the property Database.Connection.ConnectionString of one of your DbContext instances to be sure that it is really using the correct connection? - Jonas Høgh
I've set a breakpoint on both machines at the dbcontext. Checked the connection details and they are exactly the same. Very odd though it would stop working when the project literally has only been zipped and moved to another PC - Master

1 Answers

0
votes

You can remove all migrations and add only one that named Initial_Migration ( add-migration 'Initial_Migration' and update-database).

--- reference from github.