Entity Framework Migrations Explained

  Рет қаралды 33,270

dotnet

dotnet

Күн бұрын

Пікірлер: 33
@timwitort6013
@timwitort6013 Жыл бұрын
Really excellent overview of EF migrations. But a word to KZbin content creators... if you say, "Hey, if you have any questions, leave them in the comments below and we'll answer them!", then you should actually do that. None of the questions below have been answered by James or Brice.
@chandler6595
@chandler6595 2 жыл бұрын
This is great. Thank you for covering deployments and not just local development.
@willpetersen952
@willpetersen952 2 жыл бұрын
I can't imagine how much I would learn working with Brice. What a smart guy!
@liquidpebbles
@liquidpebbles 8 ай бұрын
Great info in here. Thank you guys. Brice seems really cool and he's a solid teacher. He reminds me a lot of Scott Hanselman.
@bradgermain
@bradgermain 2 жыл бұрын
Thank you for this, it's a very good introduction to EF migrations. I have a quick question. Brice mentioned adding a new migration if you're trying to revert a change, but isn't that what the down method is supposed to be used for? If not, when would you use it, just for when you want to revert changes before updating the DB? Thanks again!
@matteobarbieri2989
@matteobarbieri2989 2 жыл бұрын
Great, when we will see part 2 of EF tutorial? :-)
@JoseSilva-gt6zj
@JoseSilva-gt6zj 2 жыл бұрын
Thank you, James! I'm following all of your videos even in your channel, they are awesome! Keep going! ;)
@AppAxis
@AppAxis Жыл бұрын
Why would you ever need to remove a database if UPDATE-database is better? #EntityFramework #DotNet #Csharp
@AizenSousuke92
@AizenSousuke92 2 жыл бұрын
Anyone has any idea how do migrations work in team environments? When I merge other people's branch to mine, what should the step be to ensure that the migrations I've created and theirs (which happens to be in between) do not conflict? Should I remove my own migration, apply theirs and re-create my own migration again?
@tehsimo
@tehsimo Жыл бұрын
This seems to be where migrations can turn into a hellscape
@kj2w
@kj2w 2 жыл бұрын
I do have a question... I've had great success with generating a sql script using Script-Migration command. However when we deploy, the customer would like to know if the number of rows in specific tables have changed before and after a migration. What I've done is manually added SQL statements (ex. DECLARE @someVariable as int; SELECT @someVariable = Count(*) FROM Table; PRINT @someVariable; GO; ) before the migration and then the same SQL statements at the end. My question now is, Is there a way to add custom SQL so that it appears at the beginning and/or end of the artifact generated by script-migration?
@SHAMITHADEVINDA
@SHAMITHADEVINDA 2 жыл бұрын
It would be also great to know how to tag project version for migrations so we can upgrade from 101.01 to 101.13 passing 01 to 12 changes
@markvl197
@markvl197 2 жыл бұрын
Can u create migrations for 2 types of databases at once eg mysql and sqlserver? Say if u have clients using your software but they want to run diff database types due to their environment stack ?
@erik9817
@erik9817 Жыл бұрын
Cool! How do I migrate from the first migration back to nothing in Azure SQL? Assuming that the database has been update with the first migration.
@erik9817
@erik9817 Жыл бұрын
Great question! It's PM> update-database 0 and PM> Remove-Migration.
@niravsanghadiya6393
@niravsanghadiya6393 Жыл бұрын
Great stuff but I have a question here. When you add any new entity to existing DbContext and then you apply migration, Why it generates all the entities instead of the one which is recently added ? Any idea ?
@divv8079
@divv8079 2 жыл бұрын
That [Required] attribute for 'Title' is no longer necessary if you have "Nullable reference types" enabled in C# right? Since the string is non-nullable EF Core would pick that up as nullable: false
@BhanuKorremula
@BhanuKorremula 2 жыл бұрын
How to use code first if we want to encrypt columns in a database?
2 жыл бұрын
I applied a migration on a production server and it cleared all data...
@mojekonto9287
@mojekonto9287 2 жыл бұрын
Oh sh*, I apply migrations automatically on every deploy :D so far, all good for the last 3 years... but first, everything gets tested on DEV environment, so we know what to expect on PROD
2 жыл бұрын
@@mojekonto9287 It was on a new website, but it was already on the production server. There were no users there yet, but still a very big problem. And the worst part is I have no idea what caused that.
@mojekonto9287
@mojekonto9287 2 жыл бұрын
@ if examining the auto-generated migrations code (the Up and Down) doesn't give any clues then maybe somebody had applied some other changes manually in between. Still, even if that was the case, i would expect that applying a migration on top of them could fail. From my experience, loss of data can usually be caused by a table column type change. Or maybe you executed a script that triggered a revert of all the migrations before applying them again. I think I have seen such approach in some automated integration tests.
2 жыл бұрын
@@mojekonto9287 Now that you mentioned, I did change a column type. OMG and will it errase all data? I had no idea!!! THANK YOU SO MUCH!
@mojekonto9287
@mojekonto9287 2 жыл бұрын
@ it may erase data only in that column, though. The rest should stay intact.
@trevortirrell
@trevortirrell 2 жыл бұрын
I see James wheels are turning. Time to update your Monkeys App and Coffee App
@haroldpepete
@haroldpepete Жыл бұрын
that looks like rails migration, ummm, convention over configuration, umm, you've been watching rails' world
Entity Framework Миграции. Лучшее для развития вашего продукта
16:01
Архитектор ПО. Александр Желнин
Рет қаралды 7 М.
УДИВИЛ ВСЕХ СВОИМ УХОДОМ!😳 #shorts
00:49
If people acted like cats 🙀😹 LeoNata family #shorts
00:22
LeoNata Family
Рет қаралды 30 МЛН
Smart Sigma Kid #funny #sigma
00:33
CRAZY GREAPA
Рет қаралды 27 МЛН
139. What Are Your Thoughts on Entity Framework Core vs. Dapper?
21:49
2 Years of C++ Programming
8:20
Zyger
Рет қаралды 7 М.
The Easiest Way To Manage Database Migrations in .NET
11:40
Nick Chapsas
Рет қаралды 40 М.
Making Entity Framework Core As Fast As Dapper
13:17
Nick Chapsas
Рет қаралды 89 М.
Stored Procedures with Entity Framework Core in .NET 6 🚀
13:51
Unboxing the Raspberry Pi CM5 Development Kit
11:36
Level 2 Jeff
Рет қаралды 57 М.
What's new in .NET 9 and C# 13
19:21
Filip Ekberg
Рет қаралды 18 М.
УДИВИЛ ВСЕХ СВОИМ УХОДОМ!😳 #shorts
00:49