Open kcadduk opened 3 years ago
Using v3.4.1 with these settings:
Settings.DatabaseType = DatabaseType.SqlServer;
Settings.TemplateType = TemplateType.EfCore3;
Settings.GeneratorType = GeneratorType.EfCore;
and this sql
CREATE TABLE CalculatedColumnNotNull
(
ID INT IDENTITY(1, 1) NOT NULL,
[Type] TINYINT NOT NULL,
IsCalendar AS CONVERT(BIT, CASE WHEN [Type] BETWEEN 0 AND 7 THEN 1 ELSE 0 END) PERSISTED NOT NULL,
IsUtilization AS CONVERT(BIT, CASE WHEN [Type] BETWEEN 8 AND 10 THEN 1 ELSE 0 END) PERSISTED NOT NULL,
CONSTRAINT PK_CalculatedColumnNotNull PRIMARY KEY NONCLUSTERED (ID ASC)
);
GO
I get the following code generated:
// CalculatedColumnNotNull
public class CalculatedColumnNotNull
{
public int Id { get; set; } // ID (Primary key)
public byte Type { get; set; } // Type
public bool IsCalendar { get; private set; } // IsCalendar
public bool IsUtilization { get; private set; } // IsUtilization
}
// CalculatedColumnNotNull
public class CalculatedColumnNotNullConfiguration : IEntityTypeConfiguration<CalculatedColumnNotNull>
{
public void Configure(EntityTypeBuilder<CalculatedColumnNotNull> builder)
{
builder.ToTable("CalculatedColumnNotNull", "dbo");
builder.HasKey(x => x.Id).HasName("PK_CalculatedColumnNotNull");
builder.Property(x => x.Id).HasColumnName(@"ID").HasColumnType("int").IsRequired().ValueGeneratedOnAdd().UseIdentityColumn();
builder.Property(x => x.Type).HasColumnName(@"Type").HasColumnType("tinyint").IsRequired();
builder.Property(x => x.IsCalendar).HasColumnName(@"IsCalendar").HasColumnType("bit").IsRequired().ValueGeneratedOnAddOrUpdate();
builder.Property(x => x.IsUtilization).HasColumnName(@"IsUtilization").HasColumnType("bit").IsRequired().ValueGeneratedOnAddOrUpdate();
}
}
That looks ok to me. What version are you using?
3.3.0
No I'm not, 3.4.1
What settings do you have for
Settings.DatabaseType
Settings.TemplateType
Settings.GeneratorType
Sorry, same here.
I wonder if I've already fixed something, but not yet released as I have the not yet released v3.4.2 version.
Copy the latest code from EF.Reverse.POCO.v3.ttinclude and paste it over your existing EF.Reverse.POCO.v3.ttinclude
file, the save your `.tt' file to regenerate.
Please let me know if this does or does not work for you.
Creating a table
Generates a model
See how the calculated properties are nullable. This isn't the case. Is this a bug?