Does SQL Server CE support schema update with NHibernate?

喜你入骨 提交于 2019-12-06 06:42:10

问题


SchemaExport seems to work, but SchemaUpdate fails - the SchemaUpdate.Exceptions contains this object:

System.NotSupportedException: The method is not supported.
in System.Data.Common.DbConnection.GetSchema(String collectionName, String[] restrictionValues)
in NHibernate.Dialect.Schema.AbstractDataBaseSchema.GetTables(String catalog, String schemaPattern, String tableNamePattern, String[] types)
in NHibernate.Tool.hbm2ddl.DatabaseMetadata.GetTableMetadata(String name, String schema, String catalog, Boolean isQuoted)
in NHibernate.Cfg.Configuration.GenerateSchemaUpdateScript(Dialect dialect, DatabaseMetadata databaseMetadata)
in NHibernate.Tool.hbm2ddl.SchemaUpdate.Execute(Action`1 scriptAction, Boolean doUpdate)

回答1:


SQL Server Compact 4 supports GetSchema - use this version instead of 3.5




回答2:


OK, I think it is of more interest why schema update will not work with the Compact Edition of MS SQL.

The stack trace implies that not a method of NHibernate fails, but the method for retrieving the current database schema. When using the dialect for MS SQL CE there actually should be a call to System.Data.SqlServerCe.SqlCeConnection.GetSchema() within the stack trace. However, only DbConnection.GetSchema() appears. This means two things:

  1. Class SqlCeConnection does not override the implementation of this method, hence the implementation of the base class will be called. However, the base class does nothing more than throwing a NotSupportedException

  2. NHibernate or the dialect suitable for MS SQL CE cannot do anything about it. So, this would be an issue to be fixed by MS



来源:https://stackoverflow.com/questions/2333499/does-sql-server-ce-support-schema-update-with-nhibernate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!