79600197

Date: 2025-04-30 11:13:56
Score: 1
Natty:
Report link

This is very very old, but still an issue that can occur. I feel however that the answer from @lajos Arpad did not really address the issue, or I did not understand your question.

How I read it is your API talks to an external database that is created by a webshop framework. You want to support a newer version of that framework, which uses a slightly different database model.

Now the problem is that when you update your DbContect (model) to the new framework, it will be incompatible with the older framework.

Your reply to @Lajos Arpad says you intend to just focus on the new framework and keep a version of the source from the older framework code.

BUT that would mean you can't easily fix issues that are present in both the older and the newer framework version without having to fix them in both source trees.

@Pedro Luz states it is not possible with a DbContext, and a solution will have to be handcrafted.

We don't use EF at present and have our own POCO classes an database context where we can adjust what is send to the database based on a database version flag that the context knows about.

Usually we only support a few versions, and eventually we can clean out specific version switches after that version is no longer in circulation.

For anybody reading this, is there (in 2025) some way to have an EF Context and Model that has fields that will be send to, or ignored by, the database at runtime so you can support multiple active versions of a database model with the same source-code. We regularly use this to put new features in production code, but no customer can see it since their database is still on a previous version. Then when it becomes time to release we upgrade the database and voila the feature lights up.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • User mentioned (1): @lajos
  • User mentioned (0): @Lajos
  • User mentioned (0): @Pedro
  • Low reputation (0.5):
Posted by: Johan Bennink