Control de versiones de esquemas con Fluent NHibernate

I've tried reading some previous answers but it's not clear whether or not any of them apply to my situation, as far as I can see. Most of the questions seem to refer to web applications. I figure I'm better off stating my requirements and going from there instead of trying to reverse-engineer advice meant for a different situation. I'm essentially asking two questions:

  • What does (Fluent) NHibernate support that would, in principle, allow me to achieve the requirements? I'd prefer to use the Fluent API if possible;
  • What am I going to have to write myself to develop a working solution?

Broadly, the requirements are as follows:

  • What I'd like to do is use FNH to persist and rehydrate models for a desktop application that would have roughly the same usage model as MS Office, for example - that is, work is kept as self-contained files which are loaded into a local instance of the application.
  • The current version of the application must be able to importar archivos de todos previous versions and preserve all information except that which is declared to the user to be unsupported; by 'import' I mean 'transcribe the model information contained in file A into new file B such that file B is fully compatible with the current version, beside that which is declared to be unsupported.'
  • The current version of the application must be able to exportar a current model to be compliant with only the most recent issue of the previous una gran diferencia version of the application. It is not required to supply legacy compatibility with any older revisions of the previous major version.
  • The nature of the product is such that updates to the file format happen fairly frequently - aim to be able to release to the user every six months or so if necessary as a ballpark figure, and are changed in development much more frequently than that.

I have no objection to writing code to handle this, provided that:

  • The coding does not take an inordinate amount of time for arbitrarily complicated changes to the schema;
  • I am able to verify whether or not the translation between versions is complete by calling the FNH API through unit tests;
  • I can verify that any given model will round-trip correctly between versions and only lose data which is declared to the user to be unsupported between product versions;

Entonces, para resumir:

  • What, if anything, does Fluent NHibernate supply to enable this kind of use-case?
  • Can the requirements be readily satisfied as they are, or will I have to make them more specific and constrained?
  • What should I investigate as to coding myself?

preguntado el 08 de noviembre de 11 a las 18:11

1 Respuestas

I would suggest using a document database, something like RavenDB, MongoDb etc, for what you are trying to do. I think these would be a better fit than trying to force a RDBMS (sql server, oracle etc) and consequently nHibernate to do something that its not all that good at. not to say that it can't, but you will end up jumping through all sort of hoops to accomplish what you are asking.

One thing to note is that Fluent Nhibernate only puts a Fluent API over the Class Mapping of nhibernate.

respondido 09 nov., 11:05

Good answer and not one I'd anticipated. NHibernate has implementations for a variety of databases - I'd idly pencilled in SQLite as a likely candidate - does it not support these types of database providers? I'm aware of the nature of Fluent, but I was wondering whether it made easy some things that would be tricky with xml config, or vice versa. What is the advantage to using one of these databases you suggest? I don't know much about databases in general, which is why I want to use an ORM to abstract them. - Volumen W.

The reason that nhibernate does not support document databases is because the way they work is completely different to a relational database. have a look at - Nathan Fisher

FNH gives you a compile time checking which is the major reaons to use if for me. In the end it becomes xml in the background that is read by nhibernate, so if there is something that cannot be done in FNH then you can still use xml mapping as needed. - Nathan Fisher

Thanks. I suppose since FNH is primarily useful for declaring table mappings, a backing store without a concept of tables isn't a good fit. Do Raven/Mongo/Other preserve referential integrity in the same way? Since I'm unfamiliar with NoSQL type solutions, I'm unsure having briefly read about them in what way they constitute a 'database'. In my mind, a DB is tables and procedures. I'm quite willing to be re-educated but am having a hard time wrapping my head around it. - Volumen W.

At the end of the day, a database is just a way to store data. - Nathan Fisher

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.