面对同样的问题,这方面是否有任何进展:http: //www.softfluent.com/product/codefluent-entities/knowledge-center/point-sql-server-producer-to-production-db-instead-of-使用枢轴生产者
感谢您的回答,
编辑:这是用于删除所有约束的代码
private static void RemoveCodeFluentConstraintsTable(IList<PivotRunnerConstraint> constraints, String connectionString)
{
using (SqlConnection con = new SqlConnection(connectionString))
{
con.Open();
// Set up a command with the given query and associate
// this with the current connection.
using (SqlCommand cmd = new SqlCommand("SELECT tables.name as tableName, default_constraints.name as constraintName FROM sys.all_columns INNER JOIN sys.tables ON all_columns.object_id = tables.object_id INNER JOIN sys.schemas ON tables.schema_id = schemas.schema_id INNER JOIN sys.default_constraints ON all_columns.default_object_id = default_constraints.object_id", con))
{
foreach (PivotRunnerConstraint constraint in constraints)
{
String tableName = constraint.ParentName;
String constraintName = constraint.Name;
if (tableName != null && constraintName != null)
{
SqlCommand cmdConstraint = new SqlCommand("ALTER TABLE [MySchema].[" + tableName + "] DROP CONSTRAINT [" + constraintName + "]", con);
cmdConstraint.ExecuteNonQuery();
}
}
//con.Close();
}
}
return;
}