public void Preprocess() { var model = ModelField.Model.Project.AllModels.Where(m => m.Name.Pascalize() == ModelName.Pascalize()).FirstOrDefault(); if (model == null) { throw new ArgumentException($"Invalid foreign key model: {ModelName}"); } RefersTo = model.AllFields.Where(f => f.Name.Pascalize() == FieldName.Pascalize()).FirstOrDefault(); if (RefersTo == null) { throw new ArgumentException($"Invalid field name in foreign key. {model.Name} does not contain field {FieldName}"); } }