Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExportSqlCE40: Export SqlCe uniqueidentifier column data to SQLite as binary #982

Open
alexey-leonovich opened this issue Apr 4, 2024 · 7 comments

Comments

@alexey-leonovich
Copy link

Hello.
If I use the following command to export my test SqlCe database to SQLite:

ExportSQLCE40.exe "Data Source=test.sdf;" "test.sql" sqlite

it creates insert statement where uniqueidentifier column data is inserted as text (e. g. '65c6b3fd-e487-464a-bf79-fb3cebe9c9bf').
Is it possible make it to create inserts as binary (e. g. X'a8828ddfef224d36935a1c66ae86ebb3')?
I've tried Data Source=entities.sdf;BinaryGUID=True; but looks like your tool doesn't understand that:

Error: System.ArgumentException: Keyword is not supported: "binaryguid".

Thank you.

@ErikEJ
Copy link
Owner

ErikEJ commented Apr 4, 2024

"BinaryGUID" is not a valid SQL Server Compact connection string keyword, correct.

There a many opinions about storage of Guids with SQLite - dotnet/efcore#15078

Is it possible make it to create inserts as binary

Anything is possible! But it would have to be an opt-in flag to avoid breaking changes - interested in doing a PR?

@alexey-leonovich
Copy link
Author

interested in doing a PR?

I'm afraid I don't have enough skills to try to make these code changes(

@ErikEJ
Copy link
Owner

ErikEJ commented Apr 20, 2024

@alexey-leonovich Is your example above using the same guid value?

If not, could you provide an example that does?

@alexey-leonovich
Copy link
Author

alexey-leonovich commented May 8, 2024

@ErikEJ sorry, missed your question somehow.
Binary form X'a8828ddfef224d36935a1c66ae86ebb3' equals to text form 'DF8D82A8-22EF-364D-935A-1C66AE86EBB3'

@ErikEJ
Copy link
Owner

ErikEJ commented May 8, 2024

How do you get from one to the other?

@alexey-leonovich
Copy link
Author

Guid guid = Guid.Parse("df8d82a8-22ef-364d-935a-1c66ae86ebb3");
var bytes = guid.ToByteArray();
var hex = new StringBuilder(bytes.Length * 2);
foreach (var b in bytes)
    hex.AppendFormat("{0:x2}", b);
var guidString = hex.ToString();

or simply via https://toolslick.com/conversion/data/guid

@ErikEJ
Copy link
Owner

ErikEJ commented May 8, 2024

Thanks, I will consider implementing an option to use this format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants