Let's get this out of the way first: I know that SessionFactory is immutable - I'm trying to change the Configuration at runtime and regenerate ISessionFactory.
Specifically, I have a Customer mapped that will have some fields added to its dynamic-component node at runtime. I would like to do something like this
var newSessionFactory = previousConfiguration
.RemoveClassMapping(typeof(Customer))
.AddXmlString(newMappingForCustomer)
.BuildSessionFactory();
However, I don't see any obvious way to remove a mapping, is there anything I can do short of regenerating the entire Configuration?
It's not possible. You'll have to regenerate the Configuration
.
My initial suggestion would be that you choose a different strategy for your model.
However, if you are determined to go with this :-), you can:
Configuration
(that does not include Customer
)MemoryStream
Customer
mapping, if neededSessionFactory
Customer
Configuration
Customer
mapping and create your final SessionFactory
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With