Sqlcipher_export unknown database error Xamarin.Forms

Hi, I`m using sqlcipher with entityframework dbcontext and I have such code:

var Encrypted = “encrypted”;

var connection = new SqliteConnection($“Filename={plainTextDbPath}”);
connection.Open();

        var command = connection.CreateCommand();
        command.CommandText = $"ATTACH DATABASE '{encryptedDbPath}' AS plaintext KEY '{Password}';";
        command.ExecuteNonQuery();

        command.CommandText = $"SELECT sqlcipher_export('{Encrypted}');"; 
        command.ExecuteNonQuery();  <---- fails here with 'unknown database encrypted'

        command.CommandText = $"DETACH DATABASE {Encrypted};";
        command.ExecuteNonQuery();

I cant undarstand what im missing.

Hi @Alex_Dobrynin

It looks like you are trying to encrypt a plaintext SQLite database, is that correct? If so you are using the incorrect alias in the call to sqlcipher_export(...). In your case, you should be performing:

command.CommandText = "SELECT sqlcipher_export('plaintext');"; 
command.ExecuteNonQuery();

Also, make sure you detach using the corrected alias as well. We have a few different examples within the documentation here, your use case is likely example #1.

Found mistake: plaintext should be changed to {Encrypted} in attach db row