Skip to content

ADO.NET: StateChange event not raised on connection state transitions #138

Description

@DaveRMaltby

Summary

DbConnection defines a StateChange event that should be raised whenever the connection transitions between states (Closed → Open, Open → Closed, etc.). The FileConnection classes change the State property directly without raising this event via OnStateChange().

What's Needed

Call OnStateChange(new StateChangeEventArgs(oldState, newState)) whenever State changes in:

  • Open() — Closed → Open
  • Close() — Open → Closed
  • ChangeDatabase() — if state transitions occur
  • Error scenarios — any transition to Broken state

Impact

Code that subscribes to StateChange (e.g., connection lifecycle logging, ORM frameworks, monitoring tools) will never receive notifications.

Standard Reference

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions