Add Identity to Entity Framework Database-First Projects [DotNet 6]

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 พ.ย. 2024

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

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

    After over 30 minutes of instructions, I'm still trying to figure out how this will apply to my life. 😁 Love You, Bro.

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

      Well thanks for watching it, I appreciate you man!

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

    Spent roughly 7 hours trying to fix this issue and found very little or no help in all the main discussion forums... This video finally saved me. I appreciate you!

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

      Great Tyson, so glad I could help!!

  • @SparkDude1000
    @SparkDude1000 14 วันที่ผ่านมา

    Excellent job!

  • @karimishaahin
    @karimishaahin 7 หลายเดือนก่อน

    This really helped med, this was exactly what I searched for.

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

    Just what I needed. Thanks Data Vids!

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

      You are welcome!

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

    Thank you! Saved me so much time!

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

    Hey thanks for the video, I think I finally found what I need. I'll follow it tomorrow :)

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

      Fantastic! Glad you found what you needed.

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

    Thank you so much brother, This video helped me to solve my problem because I wanna add identity with database-first. But I want to add a column in a table inside Nortwind database how should I do it? I tried to force Scaffold-DbContext but it clearly identity context that we added last time. any suggestion brother?

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

    Hi, I did exactly as followed but at 10:12 I don't have the Index.cshtml in the Pages folder. I only have the _ViewImports.cshtml and _ViewStart.cshtml. Where ist he problem?

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

      @Dren Ibrahimi I suspect this may be the difference between a pure razor pages application and another type of .net web application. I noticed in another app I have, which is a reactJS app I only have the two files that you specified and I need to scaffold out the full razor pages set in order to get those missing files. So this tutorial is probably only going to work for you if your going the full razor pages route. Hopefully that makes sense. Sorry if I misled you! hopefully you find a tutorial that does meet your needs and are successful in getting past this hurtle! Have a great day.

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

    Hi, I tried adding the base.OnModelCreating(builder) from Identity context to the model context, but received an error “Cannot use local variable or local function 'builder' declared in a top-level statement in this context” any pointers much appreciated.

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

      hm, so are you following along in this video for this question? if so where is this, is that around the 25:00 mark in the video? I would check your inheritance at the top of both context classes (your context generated from scaffolding, and your identity context). so like public partial class myScaffoldedContext: myIdentityContext and then public class myIdentityContext : IdentityDbContext Is that how your inheritance is setup? If so then you want that line thats giving you trouble, base.OnModelCreating(builder); to be in the last one, the myIdentityContext class. I might be off since i'm not seeing your code but thats what I think is going on. If your doing this in a larger project, I also recommend just starting a empty project getting identity to work with a couple simple pre-defined tables to get the concepts and see it working before trying to apply this to a large pre-existing project. Hope that helps!

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

      @@DataVids Thanks for getting back to me :)
      In my inheritance class, I have myScaffoldedContext derived from myIdentityContext as follows:
      public partial class NorthwindContext : DataVids_IdentityContext
      Additionally, the myIdentityContext class is defined as:
      public class myIdentityContext : IdentityDbContext
      During the video, I observed that you copied the OnModelCreating(builder) method from the DataVids_IdentityContext class and pasted it into the NorthwindContext. However, I noticed that the pasted text changed from ‘OnModelCreating(builder)’ to ‘OnModelCreating(modelbuilder)’, which is not what you originally copied from DataVids_IdentityContext. It seems that you made modifications to the text before pasting it, but unfortunately, that part was not included in the video. Any pointers how to fix this much appreciated.

  • @sultanal-zoubi9250
    @sultanal-zoubi9250 2 ปีที่แล้ว +1

    Kindley, show us how to alter any existing table (rather than Identity ones) and how to reflect the changes into the existing db?

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

      Yes I will add this to my list of upcoming videos. Thanks for watching!

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

    If you have any issues with deployment, let me know. I have to mod web.config to make it to work. I will show you how.

  • @sultanal-zoubi9250
    @sultanal-zoubi9250 2 ปีที่แล้ว +4

    Thank you. Can you please show as how to create relationship between "AspNetUsers" table and any other custom table?

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

      In database first projects I have done this a few times by going directly to the database and adding the tables & foreign keys there - then scaffolding out to a different output folder (-output mynewfolder) and keeping the new table changes only if it would break things otherwise. There are so many different aspects that could be involved though, if your looking for a larger dependency, like for instance there are some custom fields in your new tables that should be part of registration, or a 'company' field for instance there is quite a bit of extra code needed. I will add such topics to my list for future videos. Have a great day and thanks for watching DataVids!

    • @sultanal-zoubi9250
      @sultanal-zoubi9250 ปีที่แล้ว

      @@DataVids Many thanks bro

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

      in such a case, should i update the db context too with the new one? @@DataVids

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

    7:11 my context is still confused it red underlinings... what did i miss ?

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

      Sorry for the super late reply, but I am not entirely sure there are a few possibilities so I would need more information to answer that. Perhaps this is a reference issue between your two context (pre existing, and Identity).

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

    Is it possible to do the reverse? Add ef core to an identity project?

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

      Good morning Sawyer Matteson, and sorry for the SUPER-delayed response. Yes, you may add efcore to any dotnet core, dotnet6, dotnet7.. project. Just pull down your package manager console or your powershell developer console and start scaffolding! Have a great day.

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

    Thank you so much.

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

      You are welcome Lynn!

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

    Thank you. I have been looking for this for a long time. It is simple to follow. Next thing is how you deploy this to IIS?.
    I have similar app and it fails when I access to the localhost. It failed and the error is https 500 (duende identity server). I cannot remember exactly the error stated. I can provide you the error and my code in my git if you would like too. Thanks.

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

      Hi Tong Phou! Sorry for the late response, but judging by your other comment it sounds like you got it figured out. Great job! There are so many reasons a hosted project can throw 500 errors in IIS, and a lot of times we really have to go step by step and do some deep troubleshooting. Best of luck with your project!

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

      @@DataVids Thank you for response. Yes, indeed I did figure it out (for you app only). However, the error https 500 is still issue for the other app (Dotnet core 6. with Angular). The dotnet 6 with Angular template doesn't have sql database backend. I created a project, built it and published it. It works fine until I added sql database backend to it. It WORKS in the development environment but not the IIS (after the deployment). I get the 500 error. I read error logs it says to do with Duende Identity Server. Therefore, I get its community license key and I install it and it still NOT WORKING, Still getting 500 error. I have the code in my git just in case any one want to take a look at it. I suprise that mfst did not care or response to the issue (I posted in the mfst vs2022 as well. Any way this is really up to you. My thinking is that I would like to this application used backend (api) with Angular front end. I tried it it did not work therefore I have to back to square on again. Thank you for your post.

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

    Thank you, the content is excellent, could you share the code with us?

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

    You can share database with everyone