Entity Framework Core Part 9 - The Fluent API

  Рет қаралды 16,464

Coding Tutorials

Coding Tutorials

Күн бұрын

Пікірлер: 28
@CodingTutorialsAreGo
@CodingTutorialsAreGo 4 жыл бұрын
Any questions or suggestions? Do add a comment. Source code is at github.com/JasperKent/Entity-Framework-Fluent-API Subscribe for more at: kzbin.info/door/qWQzlUDdllnLmtgfSgYTCA And if you liked it, give it a 👍!
@niroshanmanoharan4295
@niroshanmanoharan4295 3 жыл бұрын
Thank you for the reply "Auditable BaseEntity" this is my base entity when I inherited this to customer class it's automatically creating a table when doing the migration. How to ignore creating the table.
@CodingTutorialsAreGo
@CodingTutorialsAreGo 3 жыл бұрын
@@niroshanmanoharan4295 There are two ways to do inheritance in EF Core, known as Table Per Hierarchy and Table Per Type. (EF6 also has Table Per Concrete Type). Try this video for details and let me know if it helps: kzbin.info/www/bejne/Zp_HpmqQnchrarM
@robdevoer1
@robdevoer1 Жыл бұрын
I am so glad that I ran into your marvellous series today. After years of working with C# and EF you managed to fill in a few holes in my knowledge and made me understand some of my bad habits. Your clear and detailed approach in every session of this tutorial series is enjoyable and kept me engaged. A big thanks!!
@nitish_5262
@nitish_5262 Жыл бұрын
thankyou thankyou thankyou. commenting in 12.43 am thanks a lot for this explanation
@oncalldev
@oncalldev 2 жыл бұрын
Very clear explanation. Just popped in on Part 9. I'm sure I'll be circling back to view the prior tutorials as well the seeing the subsequent ones. Thanks.
@ajonescouk
@ajonescouk 3 жыл бұрын
Thanks again. I'm working my way through your videos so you may cover this later *but* it strikes me that classes designed specifically as code-first tables (the first M in MVVM) are nicely configured with attributes. Classes in my libraries (I do optics so have utility classes representing a prism, for example) can be more nicely configured using Fluent API - that way my library never has to "know" that the classes will be stored in a database but my Model library can still configure as needed. Your videos are really helping me to clean my data access code so the whole lot is going to be more logical to read back in 5 years time, thank you!
@CodingTutorialsAreGo
@CodingTutorialsAreGo 3 жыл бұрын
Yes, you're right - using the fluent API makes your entity classes ignorant of the the DB. That said, the Model in MVV-M shouldn't really be stored directly in the database. See kzbin.info/www/bejne/bGKXZoRnn9qJfqs, which covers MVC, but the M is the same.
@danielvelkov116
@danielvelkov116 3 жыл бұрын
ty colonel sanders for this tutorial
@hanspetervollhorst1
@hanspetervollhorst1 2 жыл бұрын
Don't understand why this channel has so few subscribers.
@sagivalia5041
@sagivalia5041 Жыл бұрын
Hey there, when I override the OnModelCreating method, do I need to do all the work EF does along with the special configs that I wanna do? or can I call base.OnModelCreating and then do the special configs that I want?
@CodingTutorialsAreGo
@CodingTutorialsAreGo Жыл бұрын
You should call base.OnModelCreating and then just do what is different from the conventional mapping.
@acattani
@acattani 2 жыл бұрын
Excellent lesson. Thank you.
@AshleyMathClass
@AshleyMathClass 2 жыл бұрын
do any of your EF videos show adding unique constraints on multiple columns?
@CodingTutorialsAreGo
@CodingTutorialsAreGo 2 жыл бұрын
I don't think I have, but the answer here seems to do it: stackoverflow.com/a/4950635/2667528
@coldhands92
@coldhands92 Жыл бұрын
how does without adding migrations and updating db your sql server db is getting updated just by running the project ??
@CodingTutorialsAreGo
@CodingTutorialsAreGo Жыл бұрын
That's because I use 'EnsureCreated'. It looks to see if the DB exists, and if not, creates it. I wouldn't use it in a real application because, as you say, we lose the migration history. But it's handy for demos.
@coldhands92
@coldhands92 Жыл бұрын
@@CodingTutorialsAreGo oh so are u deleting the db and re creating it everytime ?even with that for demo it's actually smart I just wanted to learn about fluent api so I didn't know how u set it up. Thanks for responding.
@zergzerg4844
@zergzerg4844 Жыл бұрын
Do I need after the whole configuring delete the OnModulcreating method?
@CodingTutorialsAreGo
@CodingTutorialsAreGo Жыл бұрын
Sorry, I don't understand.
@emreaka3965
@emreaka3965 3 жыл бұрын
Thanks!
@niroshanmanoharan4295
@niroshanmanoharan4295 3 жыл бұрын
Thank you for the video. When we using Fluent Api as a separate base class it automatically creating a table. How to avoid this? Could you please explain? public void Configure(EntityTypeBuilder builder) { builder .Property(v => v.CreatedBy) .HasMaxLength(20); builder .Property(v => v.LastModifiedBy) .HasMaxLength(20); }
@CodingTutorialsAreGo
@CodingTutorialsAreGo 3 жыл бұрын
Hi Niroshan, Thanks for the question, but I'm not really getting what the problem is. Can you add a little more information? Cheers.
@hanspetervollhorst1
@hanspetervollhorst1 2 жыл бұрын
EFCoreWeb is not in the repository
@CodingTutorialsAreGo
@CodingTutorialsAreGo 2 жыл бұрын
Sorry about that. I'll see if I can resurrect it.
@CodingTutorialsAreGo
@CodingTutorialsAreGo 2 жыл бұрын
Actually, that project is never used in what we're discussing here - I guess that's why I deleted it before I pushed.
@ohaRega
@ohaRega 3 жыл бұрын
Thank you!
@נדבשטיבל
@נדבשטיבל Жыл бұрын
Thank you!
Entity Framework Core Part 10 - Dynamic Mapping
17:05
Coding Tutorials
Рет қаралды 8 М.
Entity Framework Core Part 11 - Relationships
21:26
Coding Tutorials
Рет қаралды 26 М.
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 31 МЛН
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 20 МЛН
Миллионер | 3 - серия
36:09
Million Show
Рет қаралды 2,1 МЛН
How to create your own Fluent API in C#
11:12
Nick Chapsas
Рет қаралды 52 М.
Entity framework реализация патернов Relation.
25:06
Архитектор ПО. Александр Желнин
Рет қаралды 5 М.
HE WON!!!!!!!!!!!!!!!!!!!
30:20
GothamChess
Рет қаралды 224 М.
Making Entity Framework Core As Fast As Dapper
13:17
Nick Chapsas
Рет қаралды 89 М.
Entity Framework Core Part 12 - Inheritance
17:25
Coding Tutorials
Рет қаралды 8 М.
Entity Framework Core Part 8 - Attribute-Based Configuration
23:09
Coding Tutorials
Рет қаралды 4 М.
17 - Introduction to Fluent API | Code First | EF
12:43
Code Semantic
Рет қаралды 7 М.
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 31 МЛН