开发者

EF ASP.net app connects to db even after connection strings are deleted in web.config?

Can somebody tell me how EF/asp.net caches db entries? I have a simple mvc3 project hitting a sqlserverexpress db. I want to change the setting in the webconfig to point to a new db but even if I change the connection strings or even delete the section the app still co开发者_JAVA技巧nnects to the old database.


EF is a nice thing, but it will do some things without telling you.

You haven't given us much info, but if you're using EF Code First then your connectionstring name must match the name of the DB Context file. So if you have MoviesContext as the DB Context then you should have the same name for the connectionstring.

EF Code First uses a lot of conventions so if it doesn't find a connection string named as the DB Context it will try to connect to a SQLExpress (doesn't care if there is not one installed) and will look for/create the database with a very long name: Namespace.MovieContext.

Note: EF Code First might have gone off and created a database based on your POCO classes, if that is what you have done.

There is no caching involved in this case, it is just that EF Code First created a database for you...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜