I am currently using EF Core 6.0.15 and had been using EF 5 previously on the same code base meaning that I was able to perform migrations without seeing the current problem.
I have the following models (only showing one DateTime property to keep focus):
public class DistributionStatus
{
public DateTime ApproxDownloadedDateTime{ get; set; }
}
public class IsdIndex
{
public DateTime IoTCloudDeprecationDateTime{ get; set; }
}
and I don't have Data Annotations on either property.
Here is the dB before migration:
which shows that there is a default value of -infinity
for both DateTime properties.
Now, even though there are no changes in any of my Models, when I create the migration, I get:
migrationBuilder.AlterColumn<DateTime>(
name: "ApproxDownloadedDateTime",
table: "DistributionStatuses",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldDefaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc));
This for me raises 2 questions, which I hope I can get clarity on:
- Why is this code created to drop the default DateTime value for table
DistributionStatuses
? - Why is the same code not happening for table
IsdIndex
?
Moreover, in my model context, I am not setting default values for these tables.