Original: Https://codesmith.atlassian.net/wiki/display/Generator/Configuring+and+troubleshooting+a+Schema+Provider
The sections below would help guide, through using and configuring various Schema Providers that ship with Codesmith Gen Erator.
Creating A new connection stringplease read the Adding a new database Connection section before continuing.
The Data Source window would check to see if a schema provider supports showing Connection String designer. If it doesn ' t, then you must manually enter a valid connection string into the connection string text box. You must enter an valid connection string for the Provider Type is trying to use.
- If you ' re using the Sqlschemaprovider, connection strings follow the format used by the. NET Sqlconnection.connectionstrin G property.
- If you ' re using the Adoxschemaprovider, connection strings follow the format used by the ADO ConnectionString property.
- If you ' re using the Oracleschemaprovider, please be sure-check out the link below for creating a connection string as W Ell as the connecting to a Oracle database section below.
- If you're using the Postgreschemaprovider, please make sure the following statement are included in your ConnectionString: preload Reader = true;
For all schemaproviders and sure to use the proper ConnectionString for the Database Provider is using. A great resource for building database ConnectionStrings can is found here.
Configuring a Schema Providers behavior
A schema provider may contain additional configurable logic this changes how the schema provider behaves. For example, want to show the various schema objects for the current logged in user or allow Commandresultsch EMA information to be retrieved.
These settings can be configured in the Generator Options Schema Provider section as shown above.
Oracle Schema providerconnecting to an Oracle database
The first step is to add a new Data Source. Once the Data Source window is open, you'll want to select the Oracleschemaprovider from the Provider Type drop off men U.
Next, you'll want to click on the ellipse button (...) to build the connection string.
You can also manually enter an connection string into the Connnection string text box.
After you has filled out all of the required information, press the Test Connection button or the OK Button. If you could connect to your the Oracle Server, then you is all done. If this doesn ' t work scratching your head and thinking is out of luck. The good news is your not. You'll need to use a modified connection string, the connection Properties UI doesn ' t account for.
"This isanother type of Oracle connection string," doesn ' t rely on you has a DSN for the connection. You create a connection string based on the format used in the Tnsnames.ora file without the need to actually has one of These files on the client PC"(http://www.connectionstrings.com/oracle).
You'll need to manually configure this connection string using the initial Data Source User Interface ' s connection strin G text box (shown above). Below is a example of using an tns-less (Transparent Network substrate) connection string.
Data source= (description= (address_list= (address= (protocol=tcp) (Host=myhost))) (Port=myport (SERVER =dedicated) (SERVICE_NAME=MYORACLESID)); User Id=myusername; Password=mypassword;
Please see the following website for more information on Oracle Connection Strings.
Installing Oracle Data Access components (ODAC)
Codesmith Generator is compiled as AnyCPU. This means Generator would run as a 64bit process when you launch Generator outside of Visual Studio. If you is generating from within Visual Studio (32bit process), then Codesmith Generator libraries would run as a 32bit PR Ocess.
This was very important to understand as it determines which Schema Provider dependencies was resolved at run-time.
If you is trying to use the Oracle Schema Provider your May is presented with an error message that states a Badimageforma Texception was thrown. This can is resolved by installing the ODAC libraries.
If you is running a 64bit version of Windows, please install both the 32bit and 64bit versions.
Please visit the Oracle. NET Developer Center and download and install the latest versions of ODAC (32-bit, 64-bit). It is recommended this restart your computer after installing the ODAC libraries.
MySQL Schema Provider
If you're trying to use the MySQL Schema Provider you may encounter the error message: ' The MySQL.Data.MySQLClient i s not installed in this computer '. This error can occur because the MySQL connector/net (MySql.Data.MySqlClient dbprovider) hasn ' t been installed on Y Our machine.
Installing MySQL connector/net
Please download and install the latest MySQL. NET connector which can is found here. It is recommended this restart your computer after installing the MySQL. NET connector.
Version 6.7.4 of the MySQL connector may isn't work in some circumstances. If you run to an issue where the connector isn ' t being resolved. It is recommended so you try installing an older version of the the client.
Configuring MySQL Connector/net
The MySQL Schema Provider doesn ' t require a specific version of the MySQL managed libraries. This was because it uses dbproviderfactories when interacting with MySQL. One must update all. NET Framework 4.0 Machine.config's and add the MySQL provider to the DbProviderFactories element:
<system.data> <DbProviderFactories> <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.7.4.0, Culture=neutral, publickeytoken= C5687fc88969c44d "/> </DbProviderFactories></system.data>
Please ensure this update the version number (e.g., version=6.7.4.0) with the version of the MySQL connector/net that You installed.
The. NET Framework 4.0 machine.config ' s can is found here:
- %windir%\microsoft.net\framework\v4.0.30319\config\machine.config
- %windir%\microsoft.net\framework64\v4.0.30319\config\machine.config
SQLite Schema Provider
If you're trying to use the SQLite Schema Provider your may encounter the error message: ' the System.Data.SQLite libra RY is no installed on this computer '. This error can occur for the reasons:
- The System.Data.SQLite hasn ' t been installed on your machine.
- The System.Data.SQLite hasn ' t been properly configured.
Installing System.Data.SQLite
Codesmith Generator is compiled as AnyCPU. This means Generator would run as a 64bit process when you launch Generator outside of Visual Studio. If you is generating from within Visual Studio (32bit process), then Codesmith Generator libraries would run as a 32bit PR Ocess.
This was very important to understand as it determines which Schema Provider dependencies was resolved at RUN-TIME.
The first step is to ensure so you download and install the latest. NET Framework 4.0 version of System.Data.SQLite.
If you is running a 64bit version of Windows, please install both the 32bit and 64bit versions. You can skip the following configuration steps if you install the legacy version of System.Data.SQLite here.
The older version configures itself by adding entries into your machine.config.Configuring System.Data.SQLite
The SQLite Schema Provider doesn ' t require a specific version of the SQLite managed libraries. This was because it uses dbproviderfactories when interacting with SQLite. One must update all. NET Framework 4.0 Machine.config's and add the SQLite provider to the DbProviderFactories element:
<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 "/> </DbProviderFactories></system.data>
The. NET Framework 4.0 machine.config ' s can is found here:
- %windir%\microsoft.net\framework\v4.0.30319\config\machine.config
- %windir%\microsoft.net\framework64\v4.0.30319\config\machine.config
Next, you'll need to copy the 64bit or 32bit SQLite assemblies that were installed via the System.Data.SQLite installer To Codesmith Generators bin folder. This bin folder can is found in the installed Codesmith Generator to.
You should copy of the 64bit SQLite assemblies if you are using the "windows" bit.
Finally, you is ready to start using the SQLite Schema provider!
PostgreSQL Schema providerconnecting to a PostgreSQL database
Please follow the steps outlined in the "Creating a new connection string" sections for information on Creating a new data Source.
Please see the following website for more information on PostgreSQL Connection Strings. Additional connection string parameters can be found here.
Sure the following statement is included in your ConnectionString: preload Reader = true; Also You can limit what schema objects is returned by adding a SearchPath to your connection string.
Installing Npgsql
If you is trying to use the PostgreSQL Schema Provider your May is presented with an error message that states a FILENOTFO Und was thrown. This can is resolved by installing the Npgsql libraries.
First, you'll need to look at the error message and determine which version of the libraries need to be installed. This can is done by looking at the error message:
System.IO.FileNotFoundException:Could not load file or assembly ' Npgsql, version=2.0.11.0, Culture=neutral, Publickeytoken=5d8b90d52f46fda7 ' or one of its dependencies. The system cannot find the file specified.
The error message is telling us, we need to install version 2.0.11.0 of Npgsql. We then navigate to the Npgsql downloads sections and look for this version. You'll need to download the. NET 4.0 compiled version (e.g., ending with bin-ms.net4.0.zip). After this have been done, unblock the zipand extract the files to a folder. Next run gacutil from the elevated Visual Studio command Prompt and the GAC the the both extracted assemblies as shown below.
Gacutil-i npgsql.dllgacutil-i Mono.Security.dll
Finally, you is ready to start using the PostgreSQL Schema provider!
Configuring and Troubleshooting a Schema Provider