When I first built the website, I was using EF4 Code First (without migrations). Now my client asked me for some new features which required some refactoring of my code base. Part of the refactoring was to move my model into a separate assembly (which should’ve been done right from the start, but I did not know at that time). So anyway, now that my whole code base is changed, and almost all assembly names and namespaces were changed as well, when I deployed the website to the staging environment, EF regenerated the test database.
So my question is there anything that could be done to avoid that? I haven’t used migrations yet but is that a viable solution?
P.S: I would also like to know why that happened, I did not really change any property of any model class. Could it be that now that they belong to another namespace, they were seen by EF as a completely new model?
If you are sure that you didn’t change any table try to add:
to initialization of your application. It will remove any initialization strategy from your application an it will not create database anymore.