Search code examples
c#appdomainroslynbridge

Override dynamically created and loaded assembly


Currently i create assemblies for my application dynamically at startup. Is it possible to create new assemblies at runtime and override existing assemblies in the AppDomain?

I know that this would be possible if i work with different AppDomains and app domain bridges, but i want to avoid this.

My aim

We create an Entity-Framework DB-Context with all models dynamically at application startup. But at runtime maybe the database scheme change, and i want to have the changes represented in the entity framework dbcontext and models.


Solution

  • If the types from your dynamic assembly are used, then it cannot overridden, but if not used, it will eventually be unloaded. Then it will be possible to override it.