The Better Way to Configure Entity Framework Core

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

The way most people configure Entity Framework (EF) leaves little room for flexibility. In this video, I will show you how you can set up EF so that you can provide different configurations based on environment variables. This setup will give you much greater control over your deployment process.

Join my weekly .NET newsletter:

Subscribe for more:

Chapters
0:00 Introduction
0:06 What we're working with
1:48 Expanding EF configuration
3:14 The better way to configure EF
4:20 Options pattern
7:50 EF configuration with Options pattern
9:55 Outro
Рекомендации по теме
Комментарии
Автор

Every Saturday morning I send one .NET tip in my *newsletter* .
*672 .NET engineers* already read it. I would love to have you with us.

MilanJovanovicTech
Автор

Tutorial helped me alot, appreciate it. Channel is better then alot that I come across.

altom_weightlifting
Автор

Nice video. I have added you to my subscription list for learning.

waynehawkins
Автор

Nice video. Very elegant, Milan! Thanks.

miodragsimunovic
Автор

Congratulations for your content. It really is of excellent quality.

franklynbraudilioureyguard
Автор

Really nice solution, I'll definitely use it in future projects.

krccmsitp
Автор

I always tend to Validate these options I use Validate and ValidateOnStart, I think it's really useful. How many times you had a problem, where you were missing a key from configuration, this ValidateOnStart will break your app if validation fails, you apply validations with DataAnnotations. Great video! Want to see how you deploy the code.

stefanbogdanovic
Автор

7:10 you can use IOptionsMonitor<T> and the .CurrentValue property instead of IOptions<T> .Value to fetch the latest configuration value at runtime. Great video btw :)

joshstather
Автор

That's really pretty useful example. Thanks for video, keep it going!🙂

anaraxmed
Автор

Nice video again. Thanks for sharing. Keep it up

laptoprecaia.k.aagentsmith
Автор

Great video Milan, just subscribed to the channel and really like what you are doing, good luck with it all. Could this approach be used to read the settings from a database?

jamesevans
Автор

Hi !
Great content :)
I just would have liked to have a part where you would show what advantages we can derive from it (what does enabledetailederrors and enablesensitivedatalogging for exemple)
Regards

DeejayWazzouille
Автор

i just found your channel, with a few hours I learned a lot, hope you can make tips with how to handle deadlocks with efcore, we have an app made by other devs using efcore and its so slow, hopefully i can apply some optimizations mixing dapper avoiding and deadlocks all

MrDinakdakan
Автор

Thanks for creating awesome videos. They are very helpful. One problem I seem to have with using linq and entity framework is the outer joins. Would you be able to do a video about better and easier ways to do outer joins? My colleagues often complain that using outer joins in linq is very confusing and ugly when there is more than one outer join so they avoid it as much as possible.

foonlam
Автор

would be nice to see this paired up with a real world app in a framework like asp net boilerplate. nice work!

Tronald
Автор

Great video as usual! I would like to see your approach in configuring EF in a context of Database first and DDD Domain definition. I see someone change the domain to accomplish the EF mapping constraints. I don't like this approach too much maybe it's better to define a separate infrastructure model and mapping between the two models

manliomarchica
Автор

Nice video! I'd love to see how you would approach this for a multi-tenancy app? Given a db per tenant your connection string may differ where you need to replace some token in the connection string with a tenantId?

cheesypufs
Автор

Hi Milan,
Thanks for your video, it's awesome as usual!
I want to ask, why do you need to configure DatabaseOptions in separate class? You can simply get it from ServiceProvider right in AddDbContext as I think creating separate Setup class for it is overcomplicated. If all of it just for merging connection string with other parameters - maybe it's easier to store them in one section?
Thanks in advance

implicat
Автор

0:42 Do you have a video where you explain why you use .Set<Company>() ?

mtranchi
Автор

This is a great video, but why limit options binding to just EF configuration instead of using it for all configuration?

Steven_Olson