SchemaBuilder
Builder for creating schema definitions with tables, columns, indexes, and constraints.
public sealed class SchemaBuilder
Example
var schema = Schema.Define("inventory")
.Table("products", t => t
.Column("id", PortableTypes.Int, c => c.Identity().PrimaryKey())
.Column("name", PortableTypes.VarChar(100), c => c.NotNull())
.Column("price", PortableTypes.Decimal(10, 2), c => c.NotNull().Check("price >= 0"))
.Column("sku", PortableTypes.VarChar(50), c => c.NotNull())
.Unique("uq_products_sku", "sku"))
.Build();
Methods
Table(string, Action<TableBuilder>)
public SchemaBuilder Table(string name, Action<TableBuilder> configure)
Add a table to the schema.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String |
|
configure |
TableBuilder> |
Returns: SchemaBuilder
Table(string, string, Action<TableBuilder>)
public SchemaBuilder Table(string schema, string name, Action<TableBuilder> configure)
Add a table with explicit schema to the schema.
Parameters:
| Name | Type | Description |
|---|---|---|
schema |
String |
|
name |
String |
|
configure |
TableBuilder> |
Returns: SchemaBuilder
Build()
public SchemaDefinition Build()
Build the schema definition.
Returns: SchemaDefinition