0
votes

I have one Solution FooHQ that contains:

FooModel - Code First

FooService - A service that uses the FooModel

FooWebsite - A Website that consumes the FooService and the FooModel

ALL works!

I just created a FooWebsiteAgain

I referenced up the FooService and FooModel and whamoo.....

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

Funny thing, if i step through in debugger and force it to navigate the UnitOfWork context and browse around....

using (UnitOfWork unitOfWork = new UnitOfWork()) <<Debug here
   {
   var Customer = unitOfWork.CustomerRepository.GetCustomerByTN(TN);
   return Customer;
   }

... it wakes up and no error!

Please any ideas?

PS I am using EF 6.0.0

1
When you "browse around" in the debugger, do you actually activate a query? - Gert Arnold
child can not be displayed in results view @GertArnold but it does work as code in the next line...see above Customer is populated. - Pinch
Where is your context and specifically which project(s) do you have migrations enabled in? If you're going to share an entity between multiple projects, then that entity should only be tracked in one, or even in a totally separate project specifically for the purpose, perhaps a class library. If you have multiple contexts referencing the same entity class, then each one will need to be migrated separately, which of course is impossible if the database is the same. - Chris Pratt
@ChrisPratt the context is also in the model along with migrations, the unit of work just derives the context. - Pinch
Huh? You mean the context is defined in the same file as the model? That doesn't really matter, although it at least says that they're both in same project, I guess. However, make sure that you don't have any other contexts in your other project(s) that might be referencing this same entity. The Visual Studio generators for things like controllers have a bad habit of creating contexts/DbSets for you, even when you don't want or need them. - Chris Pratt

1 Answers

0
votes

I dont know why but when upgrading from EF 6.0 to the later 6.1.2 it works Apparently all other projects where 6.1.0 and this confused EF