Hi my friends,
I have just configured CodeSmith working ok with PostgreSQL database on NHibernate Frameworks. And I know that NHibernate.Spatial make NHibernate support PostGIS database in PostgreSQL.
Now I want to make CodeSmith working with PostGIS database. How can I do this?
Thanks for your attention,
I believe this is something the provider supports out of the box.. I know that there is no specific template and provider logic to return these custom mapped types, but the columns native type would be correct and you could generate off of the native type.
If you select a table column in the Database Explorer and look at it's Extended Properties (right click -> extended properties) or look in the properties window. You can see that the native type is the PostGIS type. The DbType property would be set to DbType.Object and their is an ExtendedProperty called "NpgsqlDbType" which would contain the Postgres DbType object mapping. I believe both the DbType properties would be incorrect (Mapped to DbType.Object).
The PostgresSchemaProvider's code can be updated to support this. We release the source code to all of our database providers. Please check your My Documents folder for (Documents\CodeSmith Generator\Samples\v5.3\Projects\CSharp\PostgreSQLSchemaProvider).
Please let us know if you have any questions.
CodeSmith Tools, LLC. Software Development Engineer
.NetTiers team | Visit http://www.nettiers.net
Does PostGIS just add data type support to an existing database? I checked out the website but they don't do a very good job at explaining what the product does apart from the homepage.
You are right, PostGIS is a extention for PostgreSQL Database Server. It just adds data type to handle geometry data, to support geographic data. Of course, PostGIS had to add some functions, operators too.
To create a PostgreSQL database with PostGIS enabled:
1. Install PostGIS for PostgreSQL
2. Create new PostgreSQL database with PostGIS template.
You may read this documents for details:
This tool is to convert shapefile (a file type which contains geographic data) to PostGIS table: http://www.sharpgis.net/post/2006/04/06/Adding-SharpMap-geometry-to-a-PostGIS-database.aspx
I think supporting PostGIS is simple for CodeSmith.
Thanks for your support, Blake!
I want to explore what you said about Extended Property above but after expand PostGIS table in Schema Explorer (CodeSmith Generate Studio), I clicked for expanding Column group but an error occured:
Specified argument was out of the range of valid values.
An error of type "ArgumentOutOfRangeException" occurred while attempting to populate schema information. Please check your data source settings and try again.
And this is trace:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
at SchemaExplorer.PostgreSQLSchemaProvider.GetNativeDbType(String type)
at SchemaExplorer.PostgreSQLSchemaProvider.GetTableColumns(String connectionString, TableSchema table)
at at.a(Object A_0)
And do you have any document for updating PostgreSQLSchemaProvider. I want to do this to support PostGIS.
I took a look at the provider code and the GetNativeDbType() method on line 1189 is throwing this exception if the type cannot be found. Please contact support (email@example.com) and we will send you a nightly build where it returns NpgsqlDbType.Text; as the default value.
To debug the provider you would need to change the provider name and description properties, fix the references to point to the program files CodeSmith Generator assemblies and then build the project to the Program Files SchemaProvider's folder.
Thanks for your support Blake,
Oh, it's simple to rebuild the provider,
The type of PostGIS is USER-DEFINED, out of range in the method GetNativeDbType(String type)
I just modified this and the exception went away. Now PostGIS type is trusted as NpgsqlDbType.Text.
I think I can modify generated source code to use with NHibernate.Spatial.
Good bye Blake!
Thanks for the update. If you could send support your changes, We will review them and possibly commit them into core .
As your suggestion, I sent the provider project to firstname.lastname@example.org.
Hope this helps.
Thanks I have received the provider.