tl;tr; How to reset migrations in Entity framework, and start with raw database
While I was working at the project for Imagine Cup. I came across to one major problem. What if I want to delete all migrations and start over with raw migration (but at same database). In my case it was due to one of my update-database, it doesn’t run correctly, some sort of error I couldn’t figure out, how to fix. I decited to start with raw migrations.
- First of all, you have to type this commandn “Update-Database -TargetMigration:0 -Force” (in Package Manager Console) it wipe out all your changes at db but models stays in it current state.
- Then you have to delete Migrations folder
- Delete __MIgrationHistory at your database it can be located in SystemTables
- and all others tables in traget db.
- (Please keep the order of steps, because if you delete first migrations folder, it’s over make new project…)
After all these steps, now we can start do your raw migration “Enable-Migration” if there is need, use “Enable-Migration -Force”. Visit here to learn how to migrate.
In one of my companies on of the first tasks was to create appllication, that will show which ORM will be the best choice for my team ( in terms of performance, support and features). Main focus of this task was performance. My company has a online shop that is generating a huge ammout of queries. This was an important task, because we planned to redesign whole project with ORM in order to improve efficiency and get rid off all the complex stored procedures with business logic.
I selected four popular ORMs (Entity framework, OpenAccess, XPO Devexpress, NHibernate). Each test was ran ten times to reject gross error (values were averaged)
Local machine – Summary
- Insert, probably you have wondering why single insert record has more time than inserting ten records. Probably its cost of first connection with database. And this problem is not only shown in insert but it’s happend in Update and Delete. The best performance has NHibernate 1 minute and 20 seconds with inserting 10k records! either OpenAccess has scored 1 minute and 39 seconds, opposite site Entity Framework with 3 minutes and 5 second and it’s the worst score.
- Update, undeniably, the fastest update has got NHibernate, it has won updating all of values but in the 10k records NHibernate just crushed his competition! 5 second . The worst time has got OpenAccess 1 minute 12 second.
- Delete, it’s very good example how syntax and features influence in speed of our queries just one ORM reached this horrible time – Entity Framework, there is no something like deleting collection and I was forced to using foreach statement to delete all items in collection (10k)! 3 minutes and 49 seconds. Other ORM done well their job but the best is XPO.
Undoubtedly the best time has NHibernate, it hasn’t lost any category and it won most of them.
After NHibernate, XPO Devexpress ranks in the second position. The worst was Entity Framework it lost the most time and its deleting time is just killing for our database.
EF version : 126.96.36.199
XPO version : 188.8.131.52
NHibernate version : 184.108.40.20600
OpenAccess version : 2012.3.1209.1