本文整理汇总了C#中Migration.CreateTable方法的典型用法代码示例。如果您正苦于以下问题:C# Migration.CreateTable方法的具体用法?C# Migration.CreateTable怎么用?C# Migration.CreateTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Migration
的用法示例。
在下文中一共展示了Migration.CreateTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTable_Should_Allow_Char3_As_PrimaryKey
public void CreateTable_Should_Allow_Char3_As_PrimaryKey() {
new InlineQuery("Northwind").Execute("IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MyTb]') AND type in (N'U')) \r\n DROP TABLE [dbo].[MyTb]");
using (Migration m = new Migration("Northwind")) {
TableSchema.Table tb = m.CreateTable("MyTb");
TableSchema.TableColumn col = new TableSchema.TableColumn(tb);
col.ColumnName = "Id";
col.DataType = System.Data.DbType.AnsiStringFixedLength;
col.MaxLength = 3;
col.IsPrimaryKey = true;
tb.AddColumn(col);
}
//pull the table out
DataService.ClearSchemaCache("Northwind");
TableSchema.Table table = DataService.GetSchema("MyTb", "Northwind");
Assert.IsNotNull(table);
Assert.AreEqual(3, table.PrimaryKey.MaxLength);
}
示例2: MigrationOnDispose
public void MigrationOnDispose()
{
//testing Rob's super-cool migration on dispose pattern
using(Migration m = new Migration("Northwind"))
{
TableSchema.Table t = m.CreateTable("DisposeTable");
t.AddPrimaryKeyColumn();
t.AddColumn("Name", DbType.String);
m.AddSubSonicStateColumns(t);
}
DataService.ClearSchemaCache("Northwind");
TableSchema.Table table = DataService.GetSchema("DisposeTable", "Northwind");
Assert.IsNotNull(table);
}