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!
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?
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?
@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.
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.
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!
@@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.
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!
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).
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.
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.
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!
@@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.
After over 30 minutes of instructions, I'm still trying to figure out how this will apply to my life. 😁 Love You, Bro.
Well thanks for watching it, I appreciate you man!
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!
Great Tyson, so glad I could help!!
Excellent job!
This really helped med, this was exactly what I searched for.
Just what I needed. Thanks Data Vids!
You are welcome!
Thank you! Saved me so much time!
Hey thanks for the video, I think I finally found what I need. I'll follow it tomorrow :)
Fantastic! Glad you found what you needed.
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?
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?
@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.
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.
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!
@@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.
Kindley, show us how to alter any existing table (rather than Identity ones) and how to reflect the changes into the existing db?
Yes I will add this to my list of upcoming videos. Thanks for watching!
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.
Thank you. Can you please show as how to create relationship between "AspNetUsers" table and any other custom table?
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!
@@DataVids Many thanks bro
in such a case, should i update the db context too with the new one? @@DataVids
7:11 my context is still confused it red underlinings... what did i miss ?
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).
Is it possible to do the reverse? Add ef core to an identity project?
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.
Thank you so much.
You are welcome Lynn!
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.
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!
@@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.
Thank you, the content is excellent, could you share the code with us?
You can share database with everyone