The mapping supported by Entity Framework Core is described in detail in Entity Framework Core documentation. dotConnect for Snowflake supports the standard Entity Framework Core mapping methods and attributes with the following specifics.
Fluent API method (attribute) | Snowflake support |
|---|---|
| ToTable(name) ([Table]) | Supported. The table is created in the schema specified in the Schema connection string parameter. |
| ToTable(name, schema) ([Table(Schema = ...)]) | Supported. The schema is created by EnsureCreated and migrations if it doesn't exist. |
| HasColumnName ([Column]) | Supported. |
| HasColumnType ([Column(TypeName = ...)]) | Supported. Use Snowflake type names, for example, NUMBER(12, 2), VARCHAR(100), VARIANT, GEOGRAPHY, TIMESTAMP_LTZ. For more information, see Entity Framework Core Data Type Mapping. |
| HasMaxLength ([MaxLength], [StringLength]) | Supported for strings and byte arrays: the column is created as VARCHAR(n) or BINARY(n). |
| HasPrecision ([Precision]) | Supported for System.Decimal: the column is created as NUMBER(p, s). Without precision and scale, System.Decimal is mapped to NUMBER(38, 10). Entity Framework Core 3.1 has no HasPrecision method: use HasColumnType, for example, HasColumnType("NUMBER(10, 2)"). |
| IsRequired ([Required]) | Supported: the column is created as NOT NULL. |
| HasDefaultValue, HasDefaultValueSql | Supported: the column is created with the DEFAULT clause. |
| HasKey ([Key]) | Supported: the key is created as PRIMARY KEY. Snowflake doesn't enforce the constraint, so it doesn't check the uniqueness of key values. |
| HasAlternateKey | Supported: the key is created as UNIQUE. Snowflake doesn't enforce the constraint. |
| HasIndex ([Index]) | Allowed in the model, but no index is created in the database: standard Snowflake tables have no indexes. Unique indexes aren't created either. |
| HasOne / HasMany / HasForeignKey | Supported: the foreign key is created in the database, but Snowflake doesn't enforce it. The ON DELETE and ON UPDATE clauses aren't added to the constraint, because Snowflake silently doesn't create a constraint with such clauses. Cascade deletes are performed by Entity Framework Core in the change tracker only. |
| HasComputedColumnSql | Supported when the table is created: the column is created as a virtual column, AS (expression). An existing column can't be changed to or from a computed column with ALTER COLUMN. |
| HasSequence, UseHiLo | Supported. See Generating Key Values. |
dotConnect for Snowflake encloses the names of tables, columns, sequences, and constraints in double quotation marks when generating SQL statements. Snowflake preserves the case of quoted identifiers, so object names match those specified in the Entity Framework Core model, for example, "Products" and "Name".
When writing SQL statements manually, for example, in raw SQL queries or in Snowsight, use double quotation marks and match the original case of table and column names:
Snowflake converts unquoted identifiers to uppercase, so SELECT Name FROM Products fails with the "invalid identifier" or "does not exist" error. To reference database objects without quotation marks, configure their names in uppercase in the entity model using methods such as ToTable("PRODUCTS") and HasColumnName("NAME").