Create database with UTF8 encoding

Multi tool use
Multi tool use












2















I'd want to create database with entityframework / npgsql driver with code-first approach but also UTF encoding.



In PGAdmin 3 I'm unable to change Encoding because its field is readonly



This sql is being shown in PGAdmin when I select my database



CREATE DATABASE db
WITH OWNER = dbuser
ENCODING = 'LATIN2' <------------
TABLESPACE = pg_default
LC_COLLATE = 'pl_PL'
LC_CTYPE = 'pl_PL'
CONNECTION LIMIT = -1;


But I want to change it from LATIN2 to UTF8



I manually tried this:




SET CLIENT_ENCODING TO 'UTF8'




and




show client_encoding




returns




client_encoding_text



UTF8




but despite that PGAdmin 3 still shows that this database has an encoding "LATIN2"



and my application is receiving an exception




PostgresException: 22P05: the character 0xe2889e coding "UTF8" does not have an equivalent in "LATIN2"




So, how can I create db with UTF8 via Entityframework with NPSQL driver for postgre using context.Database.EnsureCreated()?










share|improve this question

























  • Use ENCODING 'UTF8' instead of ENCODING = 'LATIN2' in the statement that creates the database. That has nothing to do with .NET or EF by the way, unless the question is about database migrations and seeding

    – Panagiotis Kanavos
    Jan 2 at 11:37






  • 1





    Client encoding as the name says, is about the encoding used to communicate with the client. It's not the database's or column data's encoding. You can't just change the encoding of an entire database that already contains data. You'd have to convert all existing text and indexes to the new encoding. Each column can have its own encoding too, which means you'd have to check and handle each column separately.

    – Panagiotis Kanavos
    Jan 2 at 11:40













  • @PanagiotisKanavos But normally I'm not using SQL to create database. I'm using context.Database.EnsureCreated(); in C# and I'm curious whether it is possible to set encoding from that place or maybe in Context's ctor with options

    – Joelty
    Jan 2 at 11:42













  • The CREATE DATABASE statement above was not generated by Npgsql... Npgsql's EF Core provider only issues CREATE DATABASE xxx, optionally with a template and tablespace - but does not explicitly set the encoding. As such, the default encoding is used, which is UTF8 by default. Check again exactly who's creating your database.

    – Shay Rojansky
    Jan 2 at 17:23











  • @ShayRojansky I'm removing database (manually), starting my app and database is created basing on my models via context.Database.EnsureCreated()

    – Joelty
    Jan 3 at 8:18
















2















I'd want to create database with entityframework / npgsql driver with code-first approach but also UTF encoding.



In PGAdmin 3 I'm unable to change Encoding because its field is readonly



This sql is being shown in PGAdmin when I select my database



CREATE DATABASE db
WITH OWNER = dbuser
ENCODING = 'LATIN2' <------------
TABLESPACE = pg_default
LC_COLLATE = 'pl_PL'
LC_CTYPE = 'pl_PL'
CONNECTION LIMIT = -1;


But I want to change it from LATIN2 to UTF8



I manually tried this:




SET CLIENT_ENCODING TO 'UTF8'




and




show client_encoding




returns




client_encoding_text



UTF8




but despite that PGAdmin 3 still shows that this database has an encoding "LATIN2"



and my application is receiving an exception




PostgresException: 22P05: the character 0xe2889e coding "UTF8" does not have an equivalent in "LATIN2"




So, how can I create db with UTF8 via Entityframework with NPSQL driver for postgre using context.Database.EnsureCreated()?










share|improve this question

























  • Use ENCODING 'UTF8' instead of ENCODING = 'LATIN2' in the statement that creates the database. That has nothing to do with .NET or EF by the way, unless the question is about database migrations and seeding

    – Panagiotis Kanavos
    Jan 2 at 11:37






  • 1





    Client encoding as the name says, is about the encoding used to communicate with the client. It's not the database's or column data's encoding. You can't just change the encoding of an entire database that already contains data. You'd have to convert all existing text and indexes to the new encoding. Each column can have its own encoding too, which means you'd have to check and handle each column separately.

    – Panagiotis Kanavos
    Jan 2 at 11:40













  • @PanagiotisKanavos But normally I'm not using SQL to create database. I'm using context.Database.EnsureCreated(); in C# and I'm curious whether it is possible to set encoding from that place or maybe in Context's ctor with options

    – Joelty
    Jan 2 at 11:42













  • The CREATE DATABASE statement above was not generated by Npgsql... Npgsql's EF Core provider only issues CREATE DATABASE xxx, optionally with a template and tablespace - but does not explicitly set the encoding. As such, the default encoding is used, which is UTF8 by default. Check again exactly who's creating your database.

    – Shay Rojansky
    Jan 2 at 17:23











  • @ShayRojansky I'm removing database (manually), starting my app and database is created basing on my models via context.Database.EnsureCreated()

    – Joelty
    Jan 3 at 8:18














2












2








2


1






I'd want to create database with entityframework / npgsql driver with code-first approach but also UTF encoding.



In PGAdmin 3 I'm unable to change Encoding because its field is readonly



This sql is being shown in PGAdmin when I select my database



CREATE DATABASE db
WITH OWNER = dbuser
ENCODING = 'LATIN2' <------------
TABLESPACE = pg_default
LC_COLLATE = 'pl_PL'
LC_CTYPE = 'pl_PL'
CONNECTION LIMIT = -1;


But I want to change it from LATIN2 to UTF8



I manually tried this:




SET CLIENT_ENCODING TO 'UTF8'




and




show client_encoding




returns




client_encoding_text



UTF8




but despite that PGAdmin 3 still shows that this database has an encoding "LATIN2"



and my application is receiving an exception




PostgresException: 22P05: the character 0xe2889e coding "UTF8" does not have an equivalent in "LATIN2"




So, how can I create db with UTF8 via Entityframework with NPSQL driver for postgre using context.Database.EnsureCreated()?










share|improve this question
















I'd want to create database with entityframework / npgsql driver with code-first approach but also UTF encoding.



In PGAdmin 3 I'm unable to change Encoding because its field is readonly



This sql is being shown in PGAdmin when I select my database



CREATE DATABASE db
WITH OWNER = dbuser
ENCODING = 'LATIN2' <------------
TABLESPACE = pg_default
LC_COLLATE = 'pl_PL'
LC_CTYPE = 'pl_PL'
CONNECTION LIMIT = -1;


But I want to change it from LATIN2 to UTF8



I manually tried this:




SET CLIENT_ENCODING TO 'UTF8'




and




show client_encoding




returns




client_encoding_text



UTF8




but despite that PGAdmin 3 still shows that this database has an encoding "LATIN2"



and my application is receiving an exception




PostgresException: 22P05: the character 0xe2889e coding "UTF8" does not have an equivalent in "LATIN2"




So, how can I create db with UTF8 via Entityframework with NPSQL driver for postgre using context.Database.EnsureCreated()?







c# postgresql .net-core entity-framework-core npgsql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 11:56









Uwe Keim

27.6k32132213




27.6k32132213










asked Jan 2 at 11:23









JoeltyJoelty

28010




28010













  • Use ENCODING 'UTF8' instead of ENCODING = 'LATIN2' in the statement that creates the database. That has nothing to do with .NET or EF by the way, unless the question is about database migrations and seeding

    – Panagiotis Kanavos
    Jan 2 at 11:37






  • 1





    Client encoding as the name says, is about the encoding used to communicate with the client. It's not the database's or column data's encoding. You can't just change the encoding of an entire database that already contains data. You'd have to convert all existing text and indexes to the new encoding. Each column can have its own encoding too, which means you'd have to check and handle each column separately.

    – Panagiotis Kanavos
    Jan 2 at 11:40













  • @PanagiotisKanavos But normally I'm not using SQL to create database. I'm using context.Database.EnsureCreated(); in C# and I'm curious whether it is possible to set encoding from that place or maybe in Context's ctor with options

    – Joelty
    Jan 2 at 11:42













  • The CREATE DATABASE statement above was not generated by Npgsql... Npgsql's EF Core provider only issues CREATE DATABASE xxx, optionally with a template and tablespace - but does not explicitly set the encoding. As such, the default encoding is used, which is UTF8 by default. Check again exactly who's creating your database.

    – Shay Rojansky
    Jan 2 at 17:23











  • @ShayRojansky I'm removing database (manually), starting my app and database is created basing on my models via context.Database.EnsureCreated()

    – Joelty
    Jan 3 at 8:18



















  • Use ENCODING 'UTF8' instead of ENCODING = 'LATIN2' in the statement that creates the database. That has nothing to do with .NET or EF by the way, unless the question is about database migrations and seeding

    – Panagiotis Kanavos
    Jan 2 at 11:37






  • 1





    Client encoding as the name says, is about the encoding used to communicate with the client. It's not the database's or column data's encoding. You can't just change the encoding of an entire database that already contains data. You'd have to convert all existing text and indexes to the new encoding. Each column can have its own encoding too, which means you'd have to check and handle each column separately.

    – Panagiotis Kanavos
    Jan 2 at 11:40













  • @PanagiotisKanavos But normally I'm not using SQL to create database. I'm using context.Database.EnsureCreated(); in C# and I'm curious whether it is possible to set encoding from that place or maybe in Context's ctor with options

    – Joelty
    Jan 2 at 11:42













  • The CREATE DATABASE statement above was not generated by Npgsql... Npgsql's EF Core provider only issues CREATE DATABASE xxx, optionally with a template and tablespace - but does not explicitly set the encoding. As such, the default encoding is used, which is UTF8 by default. Check again exactly who's creating your database.

    – Shay Rojansky
    Jan 2 at 17:23











  • @ShayRojansky I'm removing database (manually), starting my app and database is created basing on my models via context.Database.EnsureCreated()

    – Joelty
    Jan 3 at 8:18

















Use ENCODING 'UTF8' instead of ENCODING = 'LATIN2' in the statement that creates the database. That has nothing to do with .NET or EF by the way, unless the question is about database migrations and seeding

– Panagiotis Kanavos
Jan 2 at 11:37





Use ENCODING 'UTF8' instead of ENCODING = 'LATIN2' in the statement that creates the database. That has nothing to do with .NET or EF by the way, unless the question is about database migrations and seeding

– Panagiotis Kanavos
Jan 2 at 11:37




1




1





Client encoding as the name says, is about the encoding used to communicate with the client. It's not the database's or column data's encoding. You can't just change the encoding of an entire database that already contains data. You'd have to convert all existing text and indexes to the new encoding. Each column can have its own encoding too, which means you'd have to check and handle each column separately.

– Panagiotis Kanavos
Jan 2 at 11:40







Client encoding as the name says, is about the encoding used to communicate with the client. It's not the database's or column data's encoding. You can't just change the encoding of an entire database that already contains data. You'd have to convert all existing text and indexes to the new encoding. Each column can have its own encoding too, which means you'd have to check and handle each column separately.

– Panagiotis Kanavos
Jan 2 at 11:40















@PanagiotisKanavos But normally I'm not using SQL to create database. I'm using context.Database.EnsureCreated(); in C# and I'm curious whether it is possible to set encoding from that place or maybe in Context's ctor with options

– Joelty
Jan 2 at 11:42







@PanagiotisKanavos But normally I'm not using SQL to create database. I'm using context.Database.EnsureCreated(); in C# and I'm curious whether it is possible to set encoding from that place or maybe in Context's ctor with options

– Joelty
Jan 2 at 11:42















The CREATE DATABASE statement above was not generated by Npgsql... Npgsql's EF Core provider only issues CREATE DATABASE xxx, optionally with a template and tablespace - but does not explicitly set the encoding. As such, the default encoding is used, which is UTF8 by default. Check again exactly who's creating your database.

– Shay Rojansky
Jan 2 at 17:23





The CREATE DATABASE statement above was not generated by Npgsql... Npgsql's EF Core provider only issues CREATE DATABASE xxx, optionally with a template and tablespace - but does not explicitly set the encoding. As such, the default encoding is used, which is UTF8 by default. Check again exactly who's creating your database.

– Shay Rojansky
Jan 2 at 17:23













@ShayRojansky I'm removing database (manually), starting my app and database is created basing on my models via context.Database.EnsureCreated()

– Joelty
Jan 3 at 8:18





@ShayRojansky I'm removing database (manually), starting my app and database is created basing on my models via context.Database.EnsureCreated()

– Joelty
Jan 3 at 8:18












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54005458%2fcreate-database-with-utf8-encoding%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54005458%2fcreate-database-with-utf8-encoding%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







e3F P9cIzYkA3 v1k2u9UbQ l 4PKmGwKcjahqI,xMn8uW0WRtjPJ2POYDrbnQWA,pU0,a3T0o U
n6MHWqCoiv7xawjqoNvxptZXPDsjpzqNwMlgIDe92tVx,GQaP6or

Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas