ASP .NET Core MVC CRUD Operations with Foreign key using CodeFirst Approach

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ต.ค. 2024
  • From this tutorial you will learn to use the Foreign Key Attribute
    in Entity Framework Core to configure the Foreign Key Property.
    We use the Foreign Key to define the relationship between tables in the database.
    For Example, In Our Inventory Manager Project, which we are doing
    for couple of months now.
    Every Product has a Measurement of Unit, like PCS, Liters, Kgs etc.
    Our Product table is in relationship with the unit table.
    I mean, The name and description of the unit is stored in the unit Table
    and the unitId is stored in the Product table.
    We express this relationship by creating a UnitID Column
    in the Product table and marking it as Foreign Key.
    In this example, the Unit is the Principal entity & Product is a Dependent entity.
    From this tutorial You will also learn how to use multiple repositories
    from a Single Controller. In our Project Unit details can be only accessed
    by the Unit Repository. Whereas Our Product controller needs to read unit
    details from the units table.
    So how to solve this issue. watch it I bet you like it.
    and also you will learn in detail about the importance of Migration Commands and Pagination feature to the CRUD.
    It also explains the Sorting and Searching feature of the CRUD clearly.
    Then we will see the benefit of using the smallmoney datatype over float.
    and we will learn what is one-to-one relation and one-to-many relation.
    after that I Will show you how to create the Foreign key constraint
    between Multiple Tables.
    Finally I am very happy to share the sourcecode url of this application
    inside this video.
    and Much More....
    So please watch and put your comments.
    Sorting Module link
    • ASP.NET CORE EFCORE MV...
    previous Part Link.
    • ASP .NET Core 5 MVC pr...
    Playlist Link
    • Asp net core 5 MVC Tut...
    Thanks
    Aniz

ความคิดเห็น • 61

  • @eintech6566
    @eintech6566 2 ปีที่แล้ว +12

    You are correct Aniz, Many of tutorials listed on TH-cam are designed on single table and far from real world applications. Excellent effort. Keep up the good work.

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว

      Appreciate your response. Thank you.

  • @farrukhazadpak5149
    @farrukhazadpak5149 2 ปีที่แล้ว +2

    thanks for excellent work , you solve my problem , I search this video for 2 weeks , thanks dear friend , i Like .

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว

      You are most welcome. Stay tuned to the channel.

  • @azoredjyamo68
    @azoredjyamo68 10 หลายเดือนก่อน

    Very interesting for beginners

  • @franklint8301
    @franklint8301 2 ปีที่แล้ว +1

    Thank You My Friend, very detailed explanation. by the way thanks for the source code, I like the idea of showing the password after 15 minutes of the video. clever. lol...

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว

      You are Most welcome!

  • @itbattalion194
    @itbattalion194 2 ปีที่แล้ว +1

    very informative

  • @huntercyberdarkcyber4855
    @huntercyberdarkcyber4855 2 ปีที่แล้ว +1

    Haha thank you for posting this mate! Very helpful

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว

      You are most welcome. Happy Coding.

  • @melisarafoles3066
    @melisarafoles3066 2 ปีที่แล้ว

    Excellent Work. please release frequently. Thank You

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว

      Welcome and Cheers!!!. I will try my best

  • @purnarana9081
    @purnarana9081 2 ปีที่แล้ว

    Thank You , waiting for the next part.

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว

      You are welcome and coming soon.

  • @zenpaiempire
    @zenpaiempire 9 หลายเดือนก่อน

    can we have tutorial on creating web API's showing foreign key integrity and consuming those Web APIs from diffrent MVC web application.

  • @NadunUdana
    @NadunUdana ปีที่แล้ว

    thanks man

  • @bahhmantahmasebi
    @bahhmantahmasebi 2 ปีที่แล้ว

    nice

  • @DanielRezendePessoa
    @DanielRezendePessoa 2 ปีที่แล้ว

    Awesome!

  • @farrukhazadpak5149
    @farrukhazadpak5149 2 ปีที่แล้ว +2

    plz upload any work related to user role and user access rights and how to upload any project to server

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว +1

      Definitely, will do. Stay Tuned.

  • @Defense89
    @Defense89 2 ปีที่แล้ว

    wow thx alot!!!! your tutorial was awesome!!! but how to do it with an api? like postman how to pass complexe data in the postman's json format?

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว +1

      You are most welcome. very soon I will create videos on API. the whole idea is to convert this project in to microservices using API's. Actually I am little busy in my office project. will definitely do it when time permits.

  • @kholerohit4323
    @kholerohit4323 2 ปีที่แล้ว +2

    Bro can u share link of full source code because it's half source code there is not main products in it plz send link of full source code ASAP

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว

      soon will be sharing the code with products model.

  • @kamajo7518
    @kamajo7518 2 ปีที่แล้ว

    Hi Aniz, thanks again for the helpful video, it had some benefit. But the problem is that if you use restrictions in the repository for the delete method, then the items cannot be edited or changed. Any idea how to solve this problem? Thanks for your videos, they are very enjoyable and sometimes I laugh with you! :)

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว

      Thanks for watching. But why it cannot be edited or changed. it can be modified very much. could you please explain your doubt clearly. and tell me where you face the issues?

    • @kamajo7518
      @kamajo7518 2 ปีที่แล้ว

      @@CodeSbyAniz Hi Aniz, yes. So when I try to change or update my product record I get an exception that goes like this: “ The property 'Product.ProductId' has a temporary value while attempting to change the entity's state to 'Modified'. Either set a permanent value explicitly, or ensure that the database is configured to generate values for this property.“ I have a larger application and I use a remote DB. It is difficult to briefly describe the issue here in the comments. Maybe a bug on the ASP.Net side? And just for information, I'm using ASP.Net core 6 for my needs.
      Thanks for your replay. Kamil

  • @DailySpace16
    @DailySpace16 2 ปีที่แล้ว

    why you use paginatedlist in getunit method . can you explain about it more. is there another way to bind unit item ?

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว

      yes , you can do without paginated list also. There is a video of the same concept without paginated list.
      please watch this th-cam.com/video/O57nsLyZubc/w-d-xo.html

  • @attiqurrahman5573
    @attiqurrahman5573 2 ปีที่แล้ว

    Thanks, do u have a playlist where u explain everything of this project from zero ?

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว +1

      Welcome. playlist is the description of the video. please check. Thank you.

  • @АлександрКудрявцев-щ9ъ
    @АлександрКудрявцев-щ9ъ 2 ปีที่แล้ว

    Good afternoon, Thank you very much for your work.
    An error occurred, "The field Cost must be a number".
    The code is exactly like yours.

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว

      I did not get any error. could you please send a detail with screen shots to codesbyaniz@gmail.com. Thanks

  • @anbuanbu6591
    @anbuanbu6591 2 ปีที่แล้ว

    Hi, why we use interface? we directly use product repository. Kindly provide reason for interface repository.

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว

      I am planning to release a video on interfaces. on that time this will get cleared.

  • @abdullahquhtani4247
    @abdullahquhtani4247 2 ปีที่แล้ว

    Do you do paid tasks?

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว

      Sorry , I am very busy now.

  • @clovisrodyt
    @clovisrodyt 2 ปีที่แล้ว +1

    Sorry, but... Is the source code file password protected ? Thanks

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว +1

      Welcome, Password is shown in the video. please watch the video.

    • @bahhmantahmasebi
      @bahhmantahmasebi 2 ปีที่แล้ว

      @@CodeSbyAniz i watched the whole video but password doesn't appear dude

    • @kholerohit4323
      @kholerohit4323 2 ปีที่แล้ว +1

      @@bahhmantahmasebi Vr@2022

    • @ramuninavya2357
      @ramuninavya2357 2 ปีที่แล้ว

      @@bahhmantahmasebi hi did u get source code link?? If yes,plz can u share that??

    • @bahhmantahmasebi
      @bahhmantahmasebi 2 ปีที่แล้ว

      @@ramuninavya2357 you can see the source code link at first of video,copy the exact link and past it in browser then it begins to download,you can find the zip file password in comments

  • @mebinayasharma
    @mebinayasharma 2 ปีที่แล้ว

    How can I refer to two foreign keys from a single table?

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว +1

      the products table is referenced from many tables like brand , category, unit etc. please watch full video.

  • @דניאלר-ע4ו
    @דניאלר-ע4ו 2 ปีที่แล้ว

    I'm trying to download the code but it requires a password

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว

      but password is shown in the video, so please watch without skipping the video.

  • @justshukri9407
    @justshukri9407 2 ปีที่แล้ว

    You didn't show how to create that repository

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว

      please follow the playlist. everything is shown from the scratch.

    • @kashanzafar1662
      @kashanzafar1662 ปีที่แล้ว

      @@CodeSbyAniz What is Password of Zip file

  • @minettembouh1598
    @minettembouh1598 ปีที่แล้ว

    Please, I cannot access the source code

    • @CodeSbyAniz
      @CodeSbyAniz  ปีที่แล้ว

      please check, the link is very much working.

  • @AbdilahiTahir
    @AbdilahiTahir 2 ปีที่แล้ว

    Where is the link😢

    • @CodeSbyAniz
      @CodeSbyAniz  2 ปีที่แล้ว

      please watch the full video without skipping , source code URL will appear in the middle. Thanks.

    • @santoshanand4867
      @santoshanand4867 2 ปีที่แล้ว

      @@CodeSbyAniz password of zip??

  • @motivationalbeast3569
    @motivationalbeast3569 2 ปีที่แล้ว

    Source code link?

  • @kashanzafar1662
    @kashanzafar1662 ปีที่แล้ว

    Please Share the Password of Zip File

  • @nilaykShah
    @nilaykShah 3 หลายเดือนก่อน

    Horrible way to demonstrate some thing. Doing copying and pasting.