Any questions or suggestions? Do add a comment. Source code is at github.com/JasperKent/Entity-Framework-Fluent-API Subscribe for more at: ua-cam.com/channels/qWQzlUDdllnLmtgfSgYTCA.html And if you liked it, give it a 👍!
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.
@@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: ua-cam.com/video/0ndu7Zhc84Q/v-deo.html
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!!
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.
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!
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 ua-cam.com/video/6145Q1juVHI/v-deo.html, which covers MVC, but the M is the same.
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?
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.
@@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.
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); }
Any questions or suggestions? Do add a comment.
Source code is at github.com/JasperKent/Entity-Framework-Fluent-API
Subscribe for more at: ua-cam.com/channels/qWQzlUDdllnLmtgfSgYTCA.html
And if you liked it, give it a 👍!
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.
@@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: ua-cam.com/video/0ndu7Zhc84Q/v-deo.html
thankyou thankyou thankyou. commenting in 12.43 am thanks a lot for this explanation
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!!
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.
ty colonel sanders for this tutorial
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!
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 ua-cam.com/video/6145Q1juVHI/v-deo.html, which covers MVC, but the M is the same.
Don't understand why this channel has so few subscribers.
Excellent lesson. Thank you.
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?
You should call base.OnModelCreating and then just do what is different from the conventional mapping.
do any of your EF videos show adding unique constraints on multiple columns?
I don't think I have, but the answer here seems to do it: stackoverflow.com/a/4950635/2667528
how does without adding migrations and updating db your sql server db is getting updated just by running the project ??
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.
@@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.
Thanks!
Do I need after the whole configuring delete the OnModulcreating method?
Sorry, I don't understand.
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);
}
Hi Niroshan, Thanks for the question, but I'm not really getting what the problem is. Can you add a little more information? Cheers.
EFCoreWeb is not in the repository
Sorry about that. I'll see if I can resurrect it.
Actually, that project is never used in what we're discussing here - I guess that's why I deleted it before I pushed.
Thank you!
Thank you!