【发布时间】:2011-03-29 22:28:44
【问题描述】:
我正在尝试在我的 EF4.1 CodeFirst 应用程序中生成数据库时运行 Elmah Sql Server DDL。
要做到这一点,在我的DbInitializer.Seed 方法中我有:
protected override void Seed(MyJobLeadsDbContext context)
{
// Run Elmah scripts
context.Database.ExecuteSqlCommand(GetElmahDDLSql);
}
GetElmahDDLSql 只是一个字符串常量,包含来自http://code.google.com/p/elmah/source/browse/trunk/src/Elmah/SQLServer.sql 的整个 DDL
不幸的是,运行时出现以下异常:
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'GO'.
Incorrect syntax near the keyword 'ALTER'.
Incorrect syntax near the keyword 'ALTER'.
Incorrect syntax near 'GO'.
Incorrect syntax near the keyword 'SET'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Must declare the scalar variable "@ErrorId".
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Must declare the scalar variable "@TotalCount".
Must declare the scalar variable "@PageIndex".
Must declare the scalar variable "@TotalCount".
Must declare the scalar variable "@Application".
Must declare the scalar variable "@PageSize".
Must declare the scalar variable "@PageSize".
Must declare the scalar variable "@Application".
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Must declare the scalar variable "@ErrorId".
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
知道如何通过 EF4.1 正确执行 DDL 吗?
【问题讨论】:
标签: c# tsql entity-framework elmah entity-framework-4.1