Entity Framework Core Part 9 - The Fluent API

Поділитися
Вставка
  • Опубліковано 2 гру 2024

КОМЕНТАРІ • 28

  • @CodingTutorialsAreGo
    @CodingTutorialsAreGo  4 роки тому +2

    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 👍!

    • @niroshanmanoharan4295
      @niroshanmanoharan4295 4 роки тому

      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  4 роки тому

      @@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

  • @nitish_5262
    @nitish_5262 Рік тому +2

    thankyou thankyou thankyou. commenting in 12.43 am thanks a lot for this explanation

  • @robdevoer1
    @robdevoer1 Рік тому +1

    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!!

  • @oncalldev
    @oncalldev 2 роки тому +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.

  • @danielvelkov116
    @danielvelkov116 3 роки тому +7

    ty colonel sanders for this tutorial

  • @ajonescouk
    @ajonescouk 3 роки тому +1

    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 ua-cam.com/video/6145Q1juVHI/v-deo.html, which covers MVC, but the M is the same.

  • @hanspetervollhorst1
    @hanspetervollhorst1 2 роки тому +3

    Don't understand why this channel has so few subscribers.

  • @acattani
    @acattani 2 роки тому +1

    Excellent lesson. Thank you.

  • @sagivalia5041
    @sagivalia5041 Рік тому +1

    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  Рік тому +1

      You should call base.OnModelCreating and then just do what is different from the conventional mapping.

  • @AshleyMathClass
    @AshleyMathClass 2 роки тому +1

    do any of your EF videos show adding unique constraints on multiple columns?

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  2 роки тому +1

      I don't think I have, but the answer here seems to do it: stackoverflow.com/a/4950635/2667528

  • @coldhands92
    @coldhands92 Рік тому +1

    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 Рік тому +1

      @@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.

  • @emreaka3965
    @emreaka3965 3 роки тому +2

    Thanks!

  • @zergzerg4844
    @zergzerg4844 Рік тому

    Do I need after the whole configuring delete the OnModulcreating method?

  • @niroshanmanoharan4295
    @niroshanmanoharan4295 4 роки тому

    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  4 роки тому +1

      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 роки тому +1

    Thank you!

  • @נדבשטיבל
    @נדבשטיבל Рік тому +1

    Thank you!