Member
53 Points
632 Posts
Jan 26, 2021 01:45 PM|kobruleht|LINK
Hi!
Development is done against base database and base DbContext.
Customers are adding additional columns to their databases and I want application to save data to those columns also. Something like
if ( DatabaseName=="Child1" ) { dynamic product = ctx.Find<Product>(123); product.CustomPrice = 12.3m; ctx.SaveChanges(); }
CustomPrice column exists only in Child1 database.
In Child2 database there may be CustomColor column:
if ( DatabaseName=="Child2" ) { dynamic product = ctx.Find<Product>(123); product.CustomColor = "white"; ctx.SaveChanges(); }
Running this code causes exception since Find<> does not return custom properties (those do not exists in base DbContext used for development).
How to allow this code to run ?
Member
53 Points
632 Posts
Re: How to create DbContext at runtime
Jan 26, 2021 01:45 PM|kobruleht|LINK
Hi!
Development is done against base database and base DbContext.
Customers are adding additional columns to their databases and I want application to save data to those columns also. Something like
CustomPrice column exists only in Child1 database.
In Child2 database there may be CustomColor column:
Running this code causes exception since Find<> does not return custom properties (those do not exists in base DbContext used for development).
How to allow this code to run ?