Database connection string and collation

前端 未结 2 405
心在旅途
心在旅途 2021-01-15 15:45

Is it possible to set connection collation within MySql connection string and how, since there\'s a default setting on the server that\'s used for new connections.

T

相关标签:
2条回答
  • 2021-01-15 16:27

    If anyone else stumbles over this problem or wants to issue a command when opening a connection: The answer regarding OnContextCreated does no longer work as the method does no longer exist/is no longer supported.

    An alternative, which I use for executing SET NAMES <character set used by the database> is to append ;initialization command=\"SET NAMES '" + CharSet + "';\" to your connection string. According to Devart's documentation this also works for PostgreSQL, MSSQL and Oracle

    This property can also be set inside EntityDeveloper when accessing the properties of the database connection and clicking on the Advanced button.

    0 讨论(0)
  • 2021-01-15 16:34

    We recommend you to implement the OnContextCreated partial method.
    You have access to the store connection in it and you can execute ADO.NET command "SET COLLATION = ..." using this connection.

    0 讨论(0)
提交回复
热议问题