I’ve got a pretty strange issue in my first try of using Entity Framework (4.1) with MVC:
I wanted to try the Database-First pattern, so I created my database in SQL Server, got my EF model from it, added a template and had my Controller generated with CRUD functions. Up to there, everything’s fine.
But my problem is with data storage. I can save data from generated form without error, but the records arent saved in my SQL base. My data have to be saved somewhere (I even tried to reboot my PC and they still are persistant).
I also changed the password of my SQL Server account in Web.Config “Entities” connection string, but data are still available.
In the other hand, I filled another table thru SQL Server Manager, but I’m unable to retreive the data in the corresponding entity…
Is there a cache, or something where my entities could be mapped to another instance of DB, or anything that can explain that?
Thanks a lot for your help!
By default Entity Framework creates a database on your local SqlExpress server. If it doesn’t find the connection string it expects, it will make up its own instead of failing. Try connection your sql server manager to the “.\sqlexpress” server and you’ll probably find your database there.
With EF 4.3 and EF Migrations I wrote a custom initializer that prevents automatic creation in case the connection string isn’t found.