【发布时间】:2020-03-12 04:54:14
【问题描述】:
这是我所知道的最接近的......
public static class Helpers
{
public static bool TableExists(this MigrationBuilder builder, string tableName)
{
bool exists = builder.Sql($@"SELECT 1 FROM sys.tables AS T
INNER JOIN sys.schemas AS S ON T.schema_id = S.schema_id
WHERE S.Name = 'SchemaName' AND T.Name = '{tableName}'");
return exists;
}
}
但是如何从 SQL 调用中获得结果呢?
【问题讨论】:
-
我也一直在尝试解决这个问题。但是,如果没有大量的工作,这似乎是不可能的。
-
@leen3o 我用 SQL 创建了表。
-
我也在想同样的事情。谁有解决办法?
标签: entity-framework entity-framework-migrations