Brief
The DbContextOptions can be supplied to the DbContext by overriding the OnConfiguring method or externally via a constructor argument.
If both are used, OnConfiguring is applied last and can overwrite options supplied to the constructor argument.
In general, inside your OnConfiguring override you are supposed to check DbContextOptionsBuilder.IsConfigured property:
Gets a value indicating whether any options have been configured.
This can be useful when you have overridden OnConfiguring to configure the context, but in some cases you also externally provide options via the context constructor. This property can be used to determine if the options have already been set, and skip some or all of the logic in OnConfiguring.
The
DbContextOptions can be supplied to the DbContext by overriding the OnConfiguring method or externally via a constructor argument.
If both are used,
OnConfiguring is applied last and can overwrite options supplied to the constructor argument.OnConfiguring override you are supposed to check DbContextOptionsBuilder.IsConfigured property:
Gets a value indicating whether any options have been configured.
This can be useful when you have overridden
OnConfiguring to configure the context, but in some cases you also externally provide options via the context constructor. This property can be used to determine if the options have already been set, and skip some or all of the logic in OnConfiguring.
Comments
Post a Comment