private static string AnnotationFactory(PropertyInfo propertyInfo, IList <EncryptedWithAttribute> encryptedAttributes)
        {
            var attribute = encryptedAttributes.First();

            var config = new EncryptedWithConfiguration
            {
                KeyName = attribute.KeyName,
                Type    = attribute.Type
            };

            return(config.Serialize());
        }
        private static string GenerateColumnEncrypted(ColumnModel column, string command)
        {
            // Obtain annotation info
            AnnotationValues values;

            column.Annotations.TryGetValue(ColumnEncryptedWithAnnotationConvention.AnnotationName, out values);
            if (values == null)
            {
                return(command);
            }

            // Do SQL generation for column using annotation value as appropriate.
            var value = values.NewValue as string;

            // Exit if no value is defined.
            if (value == null)
            {
                return(command);
            }

            // Remove any other default collation if this is a string.
            // String fields need to have BIN2 collation.
            var collate = string.Empty;

            if (column.ClrType == typeof(string))
            {
                collate = " COLLATE Latin1_General_BIN2";
                var indexOfCollation = command.IndexOf(" COLLATE ", StringComparison.InvariantCulture);
                if (indexOfCollation > 0)
                {
                    command = command.Remove(indexOfCollation);
                }
            }

            // Bind the constraint.
            var config         = EncryptedWithConfiguration.Deserialize(value);
            var encryptionType = config.Type.ToString().ToUpperInvariant();

            return(command + $"{collate} ENCRYPTED WITH (ENCRYPTION_TYPE = {encryptionType}, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = {config.KeyName}) ");
        }