So with entity framework 1.1 I had entities like this
modelBuilder.Entity<Resolution>()
.Property(r => r.Created)
.ValueGeneratedOnAddOrUpdate()
.ForSqliteHasColumnType("Timestamp")
.ForSqliteHasDefaultValueSql("CURRENT_TIMESTAMP");
modelBuilder.Entity<Resolution>()
.Property(r => r.Updated)
.ForSqliteHasColumnType("Timestamp")
.IsRequired();
which worked fine. After upgrading to .net core 2.0 and entity framework 2.0 the
.ForSqliteHasColumnType("Timestamp")
doesn't seem to be available anymore. In fact all "ForSqlite*" functions aren't there.
I upgraded the "Microsoft.EntityFrameworkCore.Sqlite" to 2.0. I have
using Microsoft.EntityFrameworkCore;
Did they change something? I can't seem to find anything in the docs other then the sql providers are not backwards compatible to .NET Core 1.1.
Thanks
I didn't find anywhere said about the changes. But you can use below code instead in EF Core 2.0.
.HasDefaultValueSql("CURRENT_TIMESTAMP");
I had a similar problem after upgrading a testproject to EF Core 2.0 yesterday, in my case the database was not SQLite, but MS SQL Server.
I had to replace
b.Property(e => e.StartDate).IsRequired().ForSqlServerHasColumnType("Date");
b.Property(e => e.LastModified).IsRequired().ForSqlServerHasColumnType("SmallDateTime");
with:
b.Property(e => e.StartDate).IsRequired().HasColumnType("Date");
b.Property(e => e.LastModified).IsRequired().HasColumnType("SmallDateTime");
But after that it was working again. I tested it by recreating the database and visually checking the newly created column definitions in MS SQL Server Management Studio.