Skip to content

Commit

Permalink
add null check
Browse files Browse the repository at this point in the history
  • Loading branch information
ILoveMyTortoise committed Jul 3, 2023
1 parent 92996f0 commit bfaf259
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,20 @@ public static void Generate(SourceProductionContext context, string solutionName

// Method content
code.StartBlock();
code.AppendLine($"foreach (var entity in _noxSolution.Domain.Entities)");
code.AppendLine("if (_noxSolution.Domain != null)");
code.StartBlock();
code.AppendLine($"_databaseConfigurator.ConfigureEntity(modelBuilder.Entity(Type.GetType(\"SampleWebApp.Domain.\" + entity.Name)), entity);");
code.AppendLine($"foreach (var entity in _noxSolution.Domain.Entities)");
code.StartBlock();
code.AppendLine("var type = Type.GetType(\"SampleWebApp.Domain.\" + entity.Name);");
code.AppendLine();
code.AppendLine("if (type != null)");
code.StartBlock();
code.AppendLine($"_databaseConfigurator.ConfigureEntity(modelBuilder.Entity(type, entity);");
code.EndBlock();
code.EndBlock();
code.AppendLine();
code.AppendLine($"base.OnModelCreating(modelBuilder);");
code.EndBlock();
code.AppendLine();
code.AppendLine($"base.OnModelCreating(modelBuilder);");

// End method
code.EndBlock();
Expand Down

0 comments on commit bfaf259

Please sign in to comment.