I setup up OrmLite’s T4 Template and chage nothing,but get many error,is there anything I got mistake or something encoding problem
It looks like its your use of non-ascii table names which isn’t supported, they need to be valid C# identifiers.
Ok but the error message showing syntax errors where by the template is likely trying to emit invalid syntax.
hi, I remove any vs_addion about t4 highlight and copy t4 source from github now it’s ok,
<system.data> <DbProviderFactories> <add name="Odbc Data Provider" invariant="System.Data.Odbc" description=".Net Framework Data Provider for Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> <add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb" type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> <add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> <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.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/> <add name="Microsoft SQL Server Compact Data Provider" invariant="System.Data.SqlServerCe.3.5" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/> <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/> <add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.0.11.91, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" /> </DbProviderFactories> </system.data>
// This file was automatically generated by the PetaPoco T4 Template // Do not make changes directly to this file - edit the template instead // // The following connection settings were used to generate this file // // Connection String Name: `` // Provider: `` // Connection String: `` // Schema: `` // Include Views:
False`
// -----------------------------------------------------------------------------------------
// Failed to load provider - is null。 参数名: providerInvariantName // -----------------------------------------------------------------------------------------
and would you please tell me how use it on sqlite3(example config), since there no sqlite provider in DbProviderFactories
We’ve never used or tested the T4 templates with Sqlite, but after quick googling around I’ve found some examples from: https://damienbod.com/2013/11/14/using-sqlite-with-net/
<connectionStrings>
<add name="ChinookContext" connectionString="Data Source=.\Chinook_Sqlite_AutoIncrementPKs.sqlite" providerName="System.Data.SQLite" />
</connectionStrings>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description="Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
If you can’t get the T4 templates to work with SQLite another option might be to import the SQLite database into SQL Server then run the T4 templates against that to generate the POCOs. Never used it but this SQLite / SQL Server Compact Toolbox VS.NET Extension looks like it can help with importing SQLite database into SQL Server.
Note: the T4 templates are for convenience only that can help bootstrap creating POCOs for OrmLite, but OrmLite is developed a code-first POCO ORM where it’s designed to start from clean POCOs which are then used to create the database, it’s not designed to support database-first which is something T4 templates can help with, but it isn’t something we support.