HighwayFramework / Highway.Data

The fastest and smoothest way to great architecture
http://hwyfwk.com
MIT License
72 stars 30 forks source link

Forcibly set the connection string's ApplicationIntent property to "readonly" in the ReadonlyDbContext. #133

Closed ericburcham closed 1 year ago

ericburcham commented 1 year ago

This pull request takes the opinion that when using a ReadonlyDbContext the ApplicationIntent on the connection string should be set to "readonly." This has the following effect:

  1. If the unaltered connection string would result in a connection to a SQL Server availability group configured for readonly routing, then the client connection is redirected to a readonly replica in the availability group.
  2. Otherwise the ApplicationIntent property of the connection string is ignored.

If the project maintainers are of the opinion that the ApplicationIntent should be determined by the consumer of the Highway.Data.EntityFramework package, then this pull request should be rejected.

trayburn commented 1 year ago

I concur this is likely a bit niave given the multi-db nature of EF. Consider adding an Application Intent like property to ContextConfiguration instead, extend DefaultConfiguration to make Read-Write the default. Then slotting a per DB strategy for ConnectionString build which can use the CC.