No video

Entity Framework Code First (2021, DotNet Core or DotNet 5)

  Рет қаралды 36,894

Data Vids

Data Vids

Күн бұрын

Пікірлер: 66
@HaydenMarek
@HaydenMarek 20 күн бұрын
Simple and to the point. Helped me to get started. Thanks!
@DanFlakes
@DanFlakes 2 жыл бұрын
As someone coming from Dapper, this saves so much time and works like magic!
@DataVids
@DataVids 2 жыл бұрын
Yes! Entity framework is so much of a time saver.
@allenbythesea
@allenbythesea 2 жыл бұрын
It's insane how much extra work you have to do for codefirst development. I'm baffled that anyone thinks this is a good idea.
@DataVids
@DataVids 2 жыл бұрын
I guess a lot of us get interested in the idea so we can rebuild a database or run a migration based ona change for a client but your right, in the end it seems to be more work. I'm doing more database first now myself.
@allenbythesea
@allenbythesea 2 жыл бұрын
@@DataVids thanks for the honest reply. I see where codefirst works in some ways but its just so much easier to make db changes in the visual editor and just right click on the edmx surface and do an 'update'. Everything works instantly.
@dizmo..
@dizmo.. Жыл бұрын
Great job! I was looking for a great guide on this topic and here it is. 🦍
@taiwobabalola4188
@taiwobabalola4188 2 жыл бұрын
Good presentation. Everything was clear. Here are my questions. 1. How do you use the data annotation to display error messages in a production environment especially the required attribute. 2. Is dependency injection supported in console or window application when using entity framework core in these environments.
@DataVids
@DataVids 2 жыл бұрын
For the first question, I think this is what you are after: docs.microsoft.com/en-us/ef/ef6/modeling/code-first/data-annotations
@DataVids
@DataVids 2 жыл бұрын
For the second question, the answer is yes. You can setup entity framework basically the same way, do codefirst or database first. Then create your dependency injection and move the query logic out into a service. This link probably doesn't directly answer your question but might be helpful since I guess the more involved portion here is really just moving the EF references out to a service, then injecting that service into your classes: docs.microsoft.com/en-us/dotnet/core/extensions/dependency-injection-usage
@agustinavilacaldera6968
@agustinavilacaldera6968 2 жыл бұрын
Excelent, your english is very clear
@DataVids
@DataVids 2 жыл бұрын
Thank you!
@hqcart1
@hqcart1 2 жыл бұрын
Thank you! i have a question, i moved from visual studio 2019 to 2021, but now how do I use the package manager, it seems I need to reset the migration and restart again?
@DataVids
@DataVids 2 жыл бұрын
@hq cart, the package manager in visual studio 2022 is for console: Tools->Nuget Package Manager-> Package Manager Console or for UI: Right click on solution or project -> Manage Nuget Packages This is pretty much the same as visual studio 2019. Yours might just not be open by default, so once you open it the first time it may resemble closer to your previous environment. Best of luck!
@emrahkzltan9798
@emrahkzltan9798 2 жыл бұрын
thank you very much, it was excellent explanation for my problems.
@DataVids
@DataVids 2 жыл бұрын
Emrah, Glad the explanation helped you!
@akshayinuk
@akshayinuk 2 жыл бұрын
Amazing Thank you for sharing
@DataVids
@DataVids 2 жыл бұрын
Thanks for watching!
@farshaadmusic8351
@farshaadmusic8351 2 жыл бұрын
Excellent... Thank you man thank you
@DataVids
@DataVids 2 жыл бұрын
You are welcome!
@VukotaDjLewu95
@VukotaDjLewu95 Жыл бұрын
Hello. I am using Mac with M1 chip. I tried command ' dotnet ef database update ' but I got this error: System.PlatformNotSupportedException: LocalDB is not supported on this platform. Do you know what is the problem? Thank you so much!
@DataVids
@DataVids Жыл бұрын
I haven't bumped into this problem before but reading your error message, it sounds like possibly your connection string needs to be fixed or if it really is the platform then you might try to run this in a VM (virtual machine using software like virtual box or vmware) to change the platform. My personal preference has never been to work on Mac's, but some of my coworkers use Mac's and they have virtual machines that they use for certain programs.
@angel_machariel
@angel_machariel Жыл бұрын
Wait a minute. Before you scaffolded and performed a database update, the database itself already exist, you only added the tables to it. Right?
@DataVids
@DataVids Жыл бұрын
This could go either way, but in most cases code-first means that there are no tables and you are designing the tables in C# then letting dotnet build the tables in your database. If the connection string you use is to a database that has some existing tables, that should be OK. If you want to have all the tables designed in SQL first then have models created from it, then you should instead do 'database first' instead of 'code first'. Hope that helps.
@angel_machariel
@angel_machariel Жыл бұрын
@@DataVids Yes, but in your code, that database did exist already, right? Then you can add tables later to it, that I get.
@ariel._.9186
@ariel._.9186 2 жыл бұрын
thank you
@DataVids
@DataVids 2 жыл бұрын
You're welcome!
@DataVids
@DataVids 3 жыл бұрын
Source code is here at this github link, but I advise watching the video first as it will explain the where/why and how to generate the generated portions..: github.com/DataVids/EntityFramework/tree/main/EFCodeFirst
@DataVids
@DataVids 3 жыл бұрын
This keeps happening where the comments show up in my email but don't make it to the channel. Perhaps your comments are being flagged? Responding to @Mitesh M If you have a local connection from your pc to sql express, then you can setup either sql server authentication or you can setup windows active directory authentication. If you use the default ad connection we can use 'trusted connection', and so your connectionstring may be similiar to this: "Server=DESKTOP-yourPCName\\SQLEXPRESS;Database=Northwind; Trusted_Connection=True;" and don't use the double backslash (just one backslash) if you are referring to the EF console command to generate scaffolding or models, etc. use the double if its in appsettings.json. Hope that helps you and/or someone else and hopefully your comments start showing up!
@PIMARINE
@PIMARINE 3 жыл бұрын
Yeah!!! It's been along time, shouldn't have left you, without a Data Vid to step to. 🤣🤣🤣1OVE.
@DataVids
@DataVids 3 жыл бұрын
Now youz CANT leave. You broke ma heart - no other data vid is like me! haha Life is crazy, good to see you still posting and funny. Cheers
@rolexpbargayo
@rolexpbargayo 2 жыл бұрын
Amazing tutorial! Thanks!
@DataVids
@DataVids 2 жыл бұрын
Glad it was helpful!
@taiwobabalola4188
@taiwobabalola4188 2 жыл бұрын
One more, in the onconfiguring override method, is it possible to pass the name of the connection string from app.config file
@DataVids
@DataVids 2 жыл бұрын
If its a webproject, then its probably appsettings.json, and you can get it like this: options.UseSqlServer(Configuration.GetConnectionString("myConnectionStringName"))); If its a winforms or wpf project then you can get it from the App.config file like this: optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["myConnectionStringName"].ConnectionString);
@Hazuuur
@Hazuuur 2 жыл бұрын
Hello, have you heard about any changes for Code First approach in .NET 6?
@DataVids
@DataVids 2 жыл бұрын
@Hazuuur it does not seem like there is a whole lot, but some minor functionality added. See here this link: docs.microsoft.com/en-us/ef/ef6/what-is-new/
@huseyincumal5259
@huseyincumal5259 2 жыл бұрын
Thank you sir
@awaishaider4263
@awaishaider4263 2 жыл бұрын
how can we make connections of it with flutter #dart using Sql Server please guide or a video suggestion?
@DataVids
@DataVids 2 жыл бұрын
Sorry, I have not yet learned Flutter/Dart, though it does sound like a good tech stack.
@m3xpl4y
@m3xpl4y 2 жыл бұрын
Hi @16:45 you use for DataAnnotation MaxLength, i use StringLength whats the diffrence
@DataVids
@DataVids 2 жыл бұрын
It looks like the recommended choice by Microsoft/MSDN for user validation is StringLength and the recommended for building a database from code first is MaxLength.
@m3xpl4y
@m3xpl4y 2 жыл бұрын
@@DataVids So my Model has MaxLength but my ViewModel will have StringLength, right? I have now in both StringLength and its working totally fine
@troymitchel4790
@troymitchel4790 2 жыл бұрын
Do you have a database first approach video?
@DataVids
@DataVids 2 жыл бұрын
I have a few: Entity framework database first: kzfaq.info/get/bejne/eN-HnrZ5p93SqaM.html MySQL database first project: kzfaq.info/get/bejne/n7GDnZZy3q3VaKs.html Add identity to existing database first project: kzfaq.info/get/bejne/a75posp7u72lmnk.html
@kaushikchauhan8557
@kaushikchauhan8557 2 жыл бұрын
This was helpful, thank you
@DataVids
@DataVids 2 жыл бұрын
You're welcome!
@sivasothytharsi1203
@sivasothytharsi1203 Жыл бұрын
sir how to create login page for pos system using sqlite and c#
@DataVids
@DataVids Жыл бұрын
It sounds like you are looking for a whole application! I think you should check out my identity videos though, these are making a login system using c# with SQL server. Doing such with SQLlight should be a minor change, but you might want to persist some of the login information outside of memory too.
@Catuchee
@Catuchee 2 жыл бұрын
thanks!
@leoaldi9379
@leoaldi9379 2 жыл бұрын
thankyou very much ! the explanation is so simple that i can easily understand the concept !
@DataVids
@DataVids 2 жыл бұрын
Leo Aldi, You are welcome!
@user-bk9zs9jr2b
@user-bk9zs9jr2b Жыл бұрын
красава, чувак
@DataVids
@DataVids Жыл бұрын
Большое спасибо! (Google translate !)
@walmartbag777
@walmartbag777 2 жыл бұрын
Thanks man!
@DataVids
@DataVids 2 жыл бұрын
You bet!
@namansharma1448
@namansharma1448 2 жыл бұрын
where can i check my connection string in ssms
@DataVids
@DataVids 2 жыл бұрын
You can look at server explorer or you can build a query to get what you want. stackoverflow.com/questions/10479763/how-to-get-the-connection-string-from-a-database
@namansharma1448
@namansharma1448 2 жыл бұрын
@@DataVids thanx i got it .amazing video btw
@STUPIDYOUTUBE_HIDINGMSGS
@STUPIDYOUTUBE_HIDINGMSGS 2 жыл бұрын
Thanks for your video, but Entity Framework is totally removed from our system, it's just too messy and difficult to maintain for all developers. It could work in a very small system but not the enterprise level! Not sure what Microsoft was thinking when they implemented this!
@DataVids
@DataVids 2 жыл бұрын
Thanks for watching DataVids Jack! Sorry you had such a bad experience, but I have worked with multiple large products and not experienced such issues - though I do think code-first is not a good fit for enterprise, you might want to look into database-first entity framework. Its nice to see in a large environment that when you regenerate the models for example, that one developers changes are going to break someone elses queries and this is a nice benefit in large dev environments when using EF.
@hector9079
@hector9079 3 жыл бұрын
Muy bueno 👍
@LamNguyen-ei6sv
@LamNguyen-ei6sv 2 жыл бұрын
i am a dog
@DataVids
@DataVids 2 жыл бұрын
Interesting!
Little brothers couldn't stay calm when they noticed a bin lorry #shorts
00:32
Fabiosa Best Lifehacks
Рет қаралды 21 МЛН
Schoolboy Runaway в реальной жизни🤣@onLI_gAmeS
00:31
МишАня
Рет қаралды 4 МЛН
Blue Food VS Red Food Emoji Mukbang
00:33
MOOMOO STUDIO [무무 스튜디오]
Рет қаралды 20 МЛН
Logging in WebAPI for DotNet6 (DotNet Core), using NLog.
28:18
ASP.NET Core Crash Course - C# App in One Hour
1:00:44
freeCodeCamp.org
Рет қаралды 1,5 МЛН
.NET 6 🚀 EF Core & SQLite with Code First Migrations
27:07
Patrick God
Рет қаралды 27 М.
Repository Pattern with C# and Entity Framework, Done Right | Mosh
26:24
Programming with Mosh
Рет қаралды 870 М.
.NET Framework vs .NET Core vs .NET vs .NET Standard vs C#
25:14
IAmTimCorey
Рет қаралды 550 М.
Little brothers couldn't stay calm when they noticed a bin lorry #shorts
00:32
Fabiosa Best Lifehacks
Рет қаралды 21 МЛН