I am trying to upgrade an EF Core 1.x project to 2.0. In 1.x I was taking advantage of provider-specific extension methods (e.g. ForSqlServerHasDefaultValueSql
/ForSqliteHasDefaultValueSql
or ForSqlServerHasColumnType
) but these seem to have been removed in 2.0.
Since each provider has its own flavor of SQL and capabilities, I need to be able to use slightly different setups or SQL strings per provider in OnModelCreating
. For example to set a default value I might have:
modelBuilder<Foo>(b =>
{
b.Property(x => x.CreateDate)
.IsRequired()
.ForSqlServerHasDefaultValueSql("getutcdate()")
.ForSqliteHasDefaultValueSql("CURRENT_TIMESTAMP");
}
How is this done in 2.0?