diff --git a/TopModel.Generator.Csharp/DbContextGenerator.cs b/TopModel.Generator.Csharp/DbContextGenerator.cs index 85bf2f3d..792bd259 100644 --- a/TopModel.Generator.Csharp/DbContextGenerator.cs +++ b/TopModel.Generator.Csharp/DbContextGenerator.cs @@ -159,7 +159,7 @@ protected virtual void HandleMainFile(string fileName, string tag, string dbCont w.WriteLine(2, $"modelBuilder.Entity<{fp.Class}>().Property(p => p.{fp.NamePascal}).HasConversion<{Config.GetImplementation(fp.Domain)?.Type ?? string.Empty}>(){(fp.Domain.Length != null ? $".HasMaxLength({fp.Domain.Length})" : string.Empty)};"); } - if (fp.Domain.Length != null && fp.Domain.Scale != null) + if (fp.Domain?.Length != null && fp.Domain?.Scale != null) { hasPropConfig = true; w.WriteLine(2, $"modelBuilder.Entity<{fp.Class}>().Property(x => x.{fp.NamePascal}).HasPrecision({fp.Domain.Length}, {fp.Domain.Scale});");