1

I'm a beginner with the use of Entity Framework : I have done a web application using EF so i created a local Sql Server database and i added a context class EFDbContext.

When i run the application in another machine i got this error :

The model backing the 'EFDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).

i think it is because the local database is missing. So i need to know:

  1. In a similaire case, How can i restore my database?
  2. What are the differences between managing databases with Sql Server Manager and the integrated connection tool in VS ?
8
  • 1
    Do you need to use the same database from the new machine or a new database? Commented Feb 23, 2014 at 19:47
  • @Kaf i have done an application , and i need to put it in another machine .So i have to use the same database Commented Feb 23, 2014 at 19:48
  • What is your connection string? if you are using localhost, you have to change it to local IP address or network name of the database hosting machine. There may be other issues (according to the error message) but first you need to make sure you can connect to the database. Commented Feb 23, 2014 at 19:50
  • 1
    Not sure what you mean by a method. But if you need to create the database in the new machine, you can use Package Manager Console and run update-database command to do it. Commented Feb 23, 2014 at 20:03
  • 1
    (1). PM> enable-migrations (2). PM> add-migration db_migrationX (3). PM> update-database. Note: you may not need (1) and (2) if you have created migrations before. Commented Feb 23, 2014 at 20:12

1 Answer 1

2

As per comments, you can create the database in the new machine using Package Manager Console. Please follow the following steps.

(1). PM> enable-migrations 
(2). PM> add-migration db_migrationX 
(3). PM> update-database.

Note: you may not need (1) and (2) if you have created migrations before.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.