我刚刚将我的应用发布到IIS服务器(localhost)。在发布的IIS上未触发种子方法
这是检查发布过程。一切顺利,文件被复制,网站开始很好,没有错误,数据库被创建。
我错过了一件事:数据。我的种子方法没有被触发,因此最初的数据丢失了。
我试着在微软网站上查看,也在StackOverflow中无济于事。
这是我的迁移配置和种子:
internal sealed class Configuration :
DbMigrationsConfiguration<CobwebsCommon.DAL.CobwebsContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
ContextKey = "CobwebsCommon.DAL.CobwebsContext";
}
protected override void Seed(CobwebsCommon.DAL.CobwebsContext context)
{
//if (System.Diagnostics.Debugger.IsAttached == false)
// System.Diagnostics.Debugger.Launch();
Logger.Info("Cobwebs DB seed started");
try
{
var db = new CobwebsContext();
DbGen dbGen = new DbGen(context);
dbGen.GenerateDb();
}
catch (Exception e)
{
Logger.Error("Error creating db: {0}", e);
}
Logger.Info("Cobwebs DB seed finished");
}
}
_“我的种子方法没有触发”_--你确定吗?你的日志记录_work_? – CodeCaster
你要保存吗?为什么你需要vardb = new CobwebsContext();' –
@CodeCaster是的,我的日志文件确实有一些行,但以上代码中没有三个 – Chiptus