I have a project using EF migrations, I just need to confirm if we need to adjust anything or maybe a parameter in case more than one person is doing changes on the DB project. For example, yesterday a coworker was adding a column in a table and pushed the changes on the git project. I did get latest and today I need to do another db change in another table and when I create a new migration, the script is pushing the change my coworker did. Is there any wrong in the configuration?
Related
Let's say I have been coding for a couple days and can't remember if I made any changes to the database. What I currently do is go to the package manager console and "add-migration" and see if any changes exist. If none, then I delete my migration. If I do have changes then I still delete my migration and re-add the migration with a better migration name that reflects the actual change.
Is there anything with Entity Framework Core that will inform me that changes exist or something that will tell me the changes that exist without actually creating a migration file and updating the snapshotContext?
I know I could look through the change logs of my db entities but it becomes a hassle when I have several commits.
I have an Entity Framework Project for a WinForms application and the approach that I'm using is Database First.
And here is my setup (I keep it as simple as possible):
Sql Database Model
Entity Framework Model
The problem is when I try to delete a department using the command:
context.Departamento.Remove(departamento)
It deletes every record on DepartamentoComputadora table instead of throwing an exception for the "On Delete No Action" constraint in the database.
The weird thing is that if I try to delete that department on my database it actually does not let me delete it because of the constraint.
Is any configuration that I am missing on EF to enforce the on delete no action?
It is weirder that the actual configuration of EF shows the behavior that I expect to have on the table.
Thank you in advance!
Actually, it was my fault with some issues with Git on Visual Studio. My model got broken when I committed staged changes and then even I was deleting, uninstalling EF, installing it again and recreating the model from scratch, some files were not deleted from my project folder and that was causing the problem.
The solution was pretty simple:
Creating a branch for the fix.
Deleting the Entity Data Model.
Uninstall EF and removed all left lines on app.config file referencing EF.
Installing EF again.
Creating the model again and committing changes.
Done.
Thank you very much!
I am trying to relate Migrations History entries to version of software by which migration was performed. So far best place for that seems additional column in Migrations History table which can be filled with software version against each migration.
This article nicely describes how to make it, however it states:
Before you start you need to know that you can customize the
migrations history table only before you apply the first migration.
I don't believe this. Is there any way of achieving this? Maybe it is possible to change this table within another migration, however I am not sure about consequences, can anyone please advice on this matter?
i am working on visual studio 2012, team project on TFS.
after my team members updated database, i tried to get the latest updates on models, i update my models from database, my models is deleted, i tried to refresh tables from database, and get latest version from source control but my model are deleted
i need your experience
thank you
Are sure you are using the same same permissions as other devs? Remember if your dev account does not have permission to a particular table in Oracle, then it will not be seen when using "Update model from database", and hence removed.
Also if you do have correct permissions, then when you select "Update model from database", if the entity/table is already imported into your data model, then you will be refreshing the entity. This process will not automatically map your database schema to your existing data model, you can however add a property to the entity in your EF model, and then map the property to the database column (this is exactly what EF does for you automatically when you delete and update normally). When you delete the entity first, then update EF knows that the table/entity has not been imported before and so will map all of the database columns automatically for you.
We are working with Code First Migrations EF 5.0.0.rc and we are having problems when two people on the team create migrations at the same time and then commit their changes.
This looks because the Update-Database compares again the latest migration model hash or something that does not have my changes because it was commited by someone else. So is based in the database state of the latest migration, and then ignoring the changes I already applied previously.
This is a very ugly behaviour when working with local databases to simplify development and remote work. I guess this should work different, always using the current model for comparison and not the latest one declared in the Migration file model hash.
Or we are doing something wrong? Anybody with this issue?
The migration tool is really awesome, but it's very difficult to work on diverse environments, remote without this feature working fine and we are struggling our head because this looks very basic feature.
Thanks,
Leonardo