According to the latest documentation for ODP.NET EF Core, a column of DateTimeOffset type should be mapped to "TIMESTAMP WITH TIMEZONE" Oracle data type.
Developer's Guide (0 Bytes)However, when creating a migration script via "dotnet ef migrations add" command, the actual type of that column is NVARCHAR2(48). I managed to make the mapping to the expected type by changing the .net data type to DateTime and the column type name to "TIMESTAMP WITH TIMEZONE", but that doesn't seem right.
Example class before the change:
[Table("ExampleTable", Schema = "MySchema")]
public class ExampleTable
{
[Column("PK")]
public int Pk { get; set; }
[Column("CREATED_AT")]
public DateTime CreatedAt { get; set; }
}
DateTime changed to DateTimeOffset:
[Table("ExampleTable", Schema = "MySchema")]
public class ExampleTable
{
[Column("PK")]
public int Pk { get; set; }
[Column("CREATED_AT")]
public DateTimeOffset CreatedAt { get; set; }
}
Actual result after running the "dotnet ef migrations add test" command:
public partial class test : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "CREATED_AT",
schema: "MySchema",
table: "ExampleTable",
type: "NVARCHAR2(48)",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "TIMESTAMP");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "CREATED_AT",
schema: "MySchema",
table: "ExampleTable",
type: "TIMESTAMP",
nullable: false,
oldClrType: typeof(string),
oldType: "NVARCHAR2(48)");
}
}
If the documentation is right, what else should I do to make this mapping to be automatic (without specifying the type name)? Or it is a bug?