public Property Add(Property newProperty) { try { var typeName = _context.Types.Find(newProperty.TypeId)?.Name; var sql = SqlOptions.GenerateInsertIntoScript(typeName, newProperty); _context.Database.ExecuteSqlCommand(sql); var property = new SqlHandler(_context).GetTypePropertiesByName(typeName) .FirstOrDefault(a => a.Key == newProperty.Key && a.TypeId == newProperty.TypeId && a.EntityId == newProperty.EntityId && a.Value == newProperty.Value); if (property.IsComplex) { SetDisplayComplexValue(property); } return(property); } catch (Exception e) { Console.WriteLine(e); return(null); } }