Asp.MVC + AR + Spatial NHibernate
I have the following setup in a test app I'm trying:
- ASP.MVC
- Castle ActiveRecord
- NHibernate Spatial
- PostGIS
I know it's a little complicated at first, but here is the deal. I have a controller that works correctly and I have my models. They live in another project, but in the same solution. The code for both is acessible.
I have a simple User model, which BTW, does not have anything spatial. I have one model that uses a Point, but this view and action does not deal with this data.
This is the exception:
NHibernateMappingException {"The constructor being called throws an exception."}
InnerEx: {"A GeometryType column has been declared, but there is no spatial dialect configured"}
Looks like that for the first time I'm debugging (or the first few times), I get an exception telling me that I no spatial dialect could be found. This is weird. Let see some code:
This is my app start method:
protected void Application_Start()
{
Ignition.StartActiveRecord();
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
}
And this is the Ignition.StartActiveRecord:
public static void StartActiveRecord()
{
开发者_运维技巧 XmlConfigurationSource source = new XmlConfigurationSource(@"path.xml");
ActiveRecordStarter.Initialize(source, GetActiveRecordTypes());
foreach (Configuration cfg in ActiveRecordMediator.GetSessionFactoryHolder().GetAllConfigurations())
{
cfg.AddAuxiliaryDatabaseObject(new SpatialAuxiliaryDatabaseObject(cfg));
//Metadata.AddMapping(cfg, MetadataClass.GeometryColumn);
//Metadata.AddMapping(cfg, MetadataClass.SpatialReferenceSystem);
}
}
My web project contains references to all needed libraries:
- NHibernate
- ActiveRecord
- NHibernate Spatial
- NHibernate Spatial (PostGIS)
Help!? this is very annoying and I can't imagine this in a production environment!
Thanks!
The exception message is "A GeometryType column has been declared, but there is no spatial dialect configured". This means... you need to configure the PostGIS dialect :)
<add key="dialect" value="NHibernate.Spatial.Dialect.PostGisDialect,NHibernate.Spatial.PostGis" />
精彩评论