Reputation: 9818
Trying to update to EntityFramework7, but having trouble finding these methods. In EF6, we could do things like this
Conventions
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
Properties
modelBuilder.Properties<DateTime>()
.Configure(c => c
.HasColumnType("datetime2")
.HasPrecision(0));
Configurations
modelBuilder.Configurations.Add(new ModuleConfig());
I have read 1 stackoverflow post, that says Configurations are no longer possible, so you have to write all this in the OnModalCreating method, which seems stupid, as the method will be massive, but maybe this was a older version?
I am using beta7
Upvotes: 1
Views: 312
Reputation: 9806
Keep in mind that beta7 is not yet feature complete, and that even RC1 will not have feature parity with EF6.
Custom conventions are on the backlog.
For properties you could something like the following;
protected override void OnModelCreating(ModelBuilder builder)
{
foreach (var type in builder.Model.EntityTypes.Where(type => type.HasClrType))
{
foreach (var property in type.Properties)
{
if (property.ClrType == typeof(DateTime))
{
builder.Entity(type.ClrType)
.Property(property.ClrType, property.Name)
.HasSqlServerColumnType("datetime2(0)");
}
}
}
}
Upvotes: 3