I'm trying to build an aspnetcore application over an existing system where the database is already created, and I'm going to add some tables over it.
I've reverse engineered the database to add the existing tables as entities to my application, and I've written my own entities that will be added later. Finally, all the entities are added to a single DbContext.
My requirement comes as follows:
Note: I prefer not to touch the generated migration code.
Is there a proper way to handle this scenario?
Is there a proper way to handle this scenario?
Editing the Migration Code is a proper way to handle this scenario.
Alternatively, you could create one DbContext with Migrations containing only the Entities mapped to Tables you want to manage using Migrations. Then create another DbContext with all the Entities which is used to read and write to the database.
Note here that your Migration Context may lack Navigation Properties, containing only the corresponding Foreign Key Properties if you don't want to add real Foreign Keys in the database refering to tables not controlled by your Migrations.