Skip to end of metadata
Go to start of metadata


Configuration files

Depending on the application type you develop, you'll deal with an app.config  or  web.config file.
You have to edit this file to add configuration for your application to use the ORM.

MacOs/Linux user

If you are Linux or MacOS user, don't forget to adapt paths format in your configuration files.

Externalization of AppSettings and ConnectionStrings sections

Our choice was to put AppSettings  and  ConnectionStrings  sections in two distinct files, but of course you can put them in the main configuration file.
If you want to externalize them like us, please add this to tell your app how to find them:

<!-- All connection strings defined in this file.-->
<connectionStrings configSource=".\Config\OsamesOrmDbConnexions.config" />
<!-- All app settings defined in this file. -->
<appSettings configSource=".\Config\OsamesOrmSqLite.config" />

Sur cette page



ORM logging configuration using System.Diagnostics

Two logging "sources" are defined in this section.

  • osamesOrmTraceSource (simple log)
  • osamesOrmDetailedTraceSource (log with stack trace).

Note

When logging sources are missing, logging will occur to default logger of System.Diagnotics.

<system.diagnostics>
  <trace autoflush="true" indentsize="2" />
  <sources>
    <source name="osamesOrmTraceSource" switchName="mySwitch" switchType="System.Diagnostics.SourceSwitch">
      <listeners>
        <clear/>
        <add name="textwriterListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="OsamesOrm.log" traceOutputOptions="DateTime">
          <!-- le filtre laisse passer les message de niveau personnalisé -->
          <filter type="System.Diagnostics.EventTypeFilter" initializeData="Verbose"/>
        </add>
      </listeners>
    </source>
    <source name="osamesOrmDetailedTraceSource" switchName="mySwitch" switchType="System.Diagnostics.SourceSwitch">
      <listeners>
        <clear/>
        <add name="textwriterListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="OsamesOrm_err_detail.log" traceOutputOptions="DateTime, Callstack">
          <!-- le filtre laisse passer les message de niveau erreur seulement -->
          <filter type="System.Diagnostics.EventTypeFilter" initializeData="Error"/>
        </add>
      </listeners>
    </source>
  </sources>
  <switches>
    <!-- un seul switch qui permet à tous les listeners d'écouter -->
    <add name="mySwitch" value="All" />
  </switches>
</system.diagnostics>

Definition of ADO.NET providers available to application

Providers should be defined in  system.data section, like in sample code below. Else ORM will not be able to detect them on the machine.

            

Attention

A single provider can be active at time at ORM level. Several ones can be declared as usable on the machine.

            

<system.data>
    <DbProviderFactories>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=1.0.94.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
      <!--<add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>-->
      <!--<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.3.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />-->
      <!--<add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.0.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />-->
    </DbProviderFactories>
  </system.data>

AppSettings and ConnectionString sections description

AppSettings section

Following keys are required :

KeyValueDescriptionSample valueNotes
configurationFolderRelative pathApplication root relative path of folder containing XML configuration files : templates and mapping\\\Config\
xmlSchemasFolderRelative pathApplication root relative path of folder containing XSD files to validate configuration XML filesConfig\xml_schemas
sqlTemplatesSchemaFileNameFile nameXSD file to validate XML templates filesqlTemplates.xsd
mappingSchemaFileNameFile nameXSD file to validate XML mapping fileomo-mapping.xsd
sqlTemplatesFileNameFile nameXML templates filesqltemplates.xml
mappingFileNameFile nameXML mapping fileomo-mapping.xml
activeDbConnectionString

Name of active connection. Identical to one of name attribute value in connectionStrings file.

OsamesMicroORM.Sqlite


contextNumber from 0 to 2

Contextual error handling mode before throwing the exception:

    • 0 : simple : log
    • 1 : console : log, standard output
    • 2 : wpf/winforms : log, pop-up display.
0

Option removed in version 0.3, cf ORM-173 - Getting issue details... STATUS

ConnectionStrings section

Definition of every usable connection string, as triplets:

  • name : connection name as defined in AppSettings
  • connectionString : connection string value, see example: Connexion String
  • providerName : invariant name of ADO.NET provider (cf DbProviderFactories, invariant attribute)

Exemple:

<add name="OsamesMicroORM.PostgreSQL" connectionString="Server=;Port=;Database=;Uid=;Pwd=;" providerName="Npgsql" />
<add name="OsamesMicroORM.Sqlite" connectionString="Data Source=|DataDirectory|\DB\Chinook_Sqlite.sqlite;Version=3;UTF8Encoding=True;Pooling=False;Max Pool Size=100;Read Only=False;" providerName="System.Data.SQLite" />
  

External links

https://www.connectionstrings.com

    
  • No labels