I'm tinkering with EF code-first strategy, after many years of being a db-first guy, and I have to admit, I like it. I made myself a little test database and I enjoy the way EF automagically generates the script to update my schema.
So having played around with a little console app, I'm now hooking up to an ASP.NET MVC UI. But now things are going wrong. Because I haven't made any changes to my schema, but the first time a try to run a db query set off by my UI, for some reason EF is trying to regenerate my schema; moreover, it's doing it wrong and failing because it's trying to modify a field that has dependencies. I can see all this happening in my SQL Server Profiler.
This is extremely weird. When I run queries from my old console app, everything works fine. When I run them from my ASP.NET project, it tries to modify my schema. I removed the possibility of UI interference by writing a query in global.asax.cs
in Application_Start
, and it still does the migration shtick.
Any ideas what I'm doing wrong? What could cause this?