Answer the question
In order to leave comments, you need to log in
How to properly update migrations and base with Entity Framework?
There is a project in which there are models and their migrations when 2 projects are merged (my model and migration appear). But on startup everything crashes. Errors about the absence of fields are displayed.
Entity Framework is used to work with the database.
Or when cloning the default branch and launching it (without merging, everything also collapses).
dev - default https://github.com/crocomoth/UtopiaCity (they changed the fields in the models and updated the migration, it does not load)
Timeline-22.1 - mine without a merge https://github.com/crocomoth/UtopiaCity/tree/Timel. .. (the project is loaded on it)
Answer the question
In order to leave comments, you need to log in
Your question is a great example of a question you don't feel like answering. Because, he is in the style of "I did something and everything broke, go to my repository and figure it out." If you want to increase the chances of a response, you need to work on the wording, describe the changes in the code that broke your application, add a description of the error, clarify whether you applied migrations to the base.
UPD
Judging by your comment, you have downloaded commits from the main branch in which fields were added to existing models. Migrations may or may not have been created. But the bottom line is that the default request specifies all the fields that are in the class. And they are not in your database.
There are several solutions:
1) If there are new migrations, then try to apply them
2) If there are no migrations but there are model changes, then make migrations and apply them (bad option, most likely in the future you will get conflict migrations from the main branch and a headache when merging branches)
3) Ignore unadded fields in the DbContext setting, if they are for you Not needed
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question