如何重新初始化dbcontext?

时间:2014-11-19 10:25:13

标签: c# entity-framework dbcontext

我的代码需要检查db中的某些数据,然后删除db,然后重新创建并重新连接到它。

问题是,我的DBContext类有一个static构造函数,由于某种原因我无法重新初始化它。

这就是我的所作所为:

AppDBContext = new AppDBContext(); 
// Here CreateConnection is called - this is good.

然后我实际删除了数据库文件

然后我只使用相同的代码:

AppDBContext = new AppDBContext();
// for some reason the CreateConnection is not called 
// and when I try to initialize the database nothing happens...

帮助!

0 个答案:

没有答案
相关问题