ASP.NET Core Web API + Entity Framework Core : Scaffold-DbContext - EP02

preview_player
Показать описание
Hey Coders,

In this #EntityFramework tutorial, I am exploring how we use parameters for #Scaffold-DBContext command to stores #ConnectionStrings in appsettings and use it from there. Also checking out how we can pluralize the DBSet names.

Content -
1. Storing Connection String in AppSettings
2. Pluralizing DbSet Property Names
3. Updating models after DB update

Scaffold-DBContext Parameters -

#CuriousDrive #WeLoveCoding
Рекомендации по теме
Комментарии
Автор

Thanks for watching, please share with your friends :)

CuriousDrive
Автор

You are doing a great job, thank you very very much. I didn't find these tutorials anywhere properly like that.

takecare
Автор

I just learned about asp.net core before I learned about vb.net. I had an error when the connection name in appsettings.json was not the same as in the tutorial, but using the -force command you don't have to bother rebuilding the Entity Framework. Thank you sir

Crealnv
Автор

You have the video I have been looking for months! Thank you dude! You are a great teacher :)

DaniLearnsIT
Автор

Very good tutorial, very well-explained in details! keep making them up please!

STUPIDYOUTUBE_HIDINGMSGS
Автор

This exception occur when running -> was not found in the application's configuration. Note that named connection strings are only supported when using 'IConfiguration' and a service provider, such as in a typical ASP.NET Core application

beautifulcultures
Автор

You're my LifeSaver bro. Keep up the good work. <3

MrPramit
Автор

Hello, really thank u for these tutorials, it is an amazing work, you explain really good, and very useful things, keep your videos as these please, simple!!

mauriciomontoya
Автор

This video was very valuable. Thank you.

thedevlife
Автор

who get erreur of sertification SSL you have to Add " ;TrustServerCertificate=true "to the connection string. This will force the client to trust the certificate without validation.

rabahkhiari
Автор

is there any way to scaffold the stored procedures too?

Hamdymohamedmohamed
Автор

#CuriousDrive , Need to encrypt the "connection string" stored in appsettings.json? (before published)
If yes, How do it? (asp.net 6) . Thank you for your answer!

rigofutty
Автор

Hi Dear,
I have a question in DB First approach.. how to exclude 2 tables out of n tables because those two tables are not going to use in my application and those tables don't have primary key that is throwing an exception. Those tables will be used by SQL jobs in the backend we need to have those tables but don't have to generate models for those tables.. could you please help me? Waiting for your answer.. Thank you.

shravansangi
Автор

Thanks for the video. I have a question, what happened if instead of Scaffold into API we have a CLASS LIBRARY and we want to Scaffold into it? how to Scaffold with a connection name? I tried and the error that I had is "A named connection string was used, but the name 'BookStoresDB' was not found in the application's configuration.
Note that named connection strings are only supported when using 'IConfiguration' and a service provider" I also added into API Startup.ConfigureServices method this code: =>

bgva
Автор

Hi, I tried to Scaffold-DbContext storing connection string and updating in the app setting and also using scaffolding db contect in package manager console to update connection string. I have an issue after I ran the Scaffold-DbContext, it's showing error "Format of the initialization string does not conform to specification starting at index 0" . Please advise me accrdingly

TripuranaLohit
Автор

When I am trying to make dbcontext and model classes under the classs librery models folder using scaffold its succedded but unable to have dbcontext and model classs after using it any help will be appreciated ?

ayushtyagi
Автор

Issue here:
I know you have addressed this in a previous comment but it doesn't work.

'A named connection string was used, but the name 'UserDB' was not found in the application's configuration.

appsettings file (I added the following):

"ConnectionStrings": {
"UserDB":
}

Then I done the command:
Scaffold-DbContext -Connection Name=UserDB -OutputDir Models -force

Then I cleaned and rebuilt the project.

Still the error is 'A named connection string was used, but the name 'UserDB' was not found in the application's configuration.

So, then I added (in services) method):
=>


rebuilt and restarted VS.

Still get the error! Any solution to this would be greatly appreciated!

Programlive
Автор

And a second thing if you use the tool - Bricelam, be careful because if one of your tables is in plural - my was cases, it changes the class to singular - cas, not case. Its not precise in that, so best practise, name your tables singular

stefanstefanov
Автор

Amazing tutorial. Please can you make a vidoe that shows how we can create this manually to connect the database and create models and all. Thansk in advance

rv
Автор

I am running into a issue that says 'No context type was found in the assembly
' I have searched various developer sites and no solution seems to help me resolve this issue. Can you help?

allanoloo