Connect NHibernate to different databases with same schema

霸气de小男生 提交于 2020-01-13 06:56:10

问题


We are in the process of splitting our db into several smaller ones. The schemas will be exactly the same and we will control which db the system connects to when the client logs in. I receive an error if I do not set a connection string in my nhibernate configuration. I do not want to create a factory for each db. Is it possible to have a session factory provide a Session that I can set the connection string before using it?


回答1:


Have not used it but there is a method ChangedDatabase on the Session.Connection. Maybe that would work?




回答2:


Maybe you can use NHibernate.Shards, in the NHcontrib repository



来源:https://stackoverflow.com/questions/1835646/connect-nhibernate-to-different-databases-with-same-schema

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