You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Question: Creating a provider without an access to DB #409
One question: it is possible (or can it be possible) to instantiate providers without requiring to have an access to DB?
Give them a schema file, or somehow similar?
This would allow building in CI easier, more reproducible builds, etc...
One question: it is possible (or can it be possible) to instantiate providers without requiring to have an access to DB?
Give them a schema file, or somehow similar?
I've investigated approach of serializing the stuff to have the SqlCommandProvider working on top of a serialized .json of the schema metadata used by the provider at design time.
It is a viable approach, but it still requires, when updating .sql files (which invalidates the .json cache) to have a dbserver.
The usual approach, as far as I'm concerned with using this library, is to have db preparation in the build script, and indeed, having that db available on the development / integration machine.
I don't have free time to commit into taking this investigation/prototype towards a stable implementation and updated version of the library, I've seen the pros/cons of the above while experimenting and it doesn't help much in my current usecase.
This question is closely related to #406 (DACPAC support) and #404 (generated types). Here's a summary of the options:
Option 1: Local DB from schema (current best workaround)
As @charlesroddie described, the practical approach is to create a local DB from your SSDT schema file as part of the build process. This gives you a real DB available at design time and in CI, without needing a full SQL Server instance.
Option 2: DACPAC-based offline schema parsing (see #406) @Thorium pointed out that SQLProvider's Ssdt.DacpacParser.fs (at fsprojects/SQLProvider) can parse a DACPAC file without a live DB connection. Adapting this for FSharp.Data.SqlClient would allow the type provider to work entirely offline using schema metadata extracted from a DACPAC. This would be a significant feature addition.
Option 3: Generated types (see #404)
A generated type provider would run once at build time, persist the generated code, and allow dependents to use it without a DB. This is the most ergonomic long-term solution but requires substantial design and implementation work.
Option 4: Schema metadata caching
As @smoothdeveloper investigated: serialising the schema metadata to JSON works, but still requires the DB when SQL files change. This reduces but doesn't eliminate the DB dependency.
If CI access to a DB is the main pain point, Option 1 with LocalDB is usually the most practical path. A minimal PowerShell or bash script that creates the LocalDB from your DACPAC's deploy script can be added as a CI step.
Activity
jackfoxy commentedon Jun 30, 2021
Pretty sure there are other SQL TPs that work off provided schemas. This project needs some fixes to be net5.0 compatible., most especially #374
charlesroddie commentedon Aug 4, 2021
You need to create a db based on a schema file. For example in our SSDT project we have this post-build event:
The powershell files are:
and
Took ages to get this right because of the terrible languages involved, but once setup the process becomes very smooth.
smoothdeveloper commentedon Sep 26, 2021
I've investigated approach of serializing the stuff to have the SqlCommandProvider working on top of a serialized .json of the schema metadata used by the provider at design time.
It is a viable approach, but it still requires, when updating .sql files (which invalidates the .json cache) to have a dbserver.
The usual approach, as far as I'm concerned with using this library, is to have db preparation in the build script, and indeed, having that db available on the development / integration machine.
I don't have free time to commit into taking this investigation/prototype towards a stable implementation and updated version of the library, I've seen the pros/cons of the above while experimenting and it doesn't help much in my current usecase.
github-actions commentedon Mar 14, 2026
🤖 This is an automated response from Repo Assist.
This question is closely related to #406 (DACPAC support) and #404 (generated types). Here's a summary of the options:
Option 1: Local DB from schema (current best workaround)
As
@charlesroddiedescribed, the practical approach is to create a local DB from your SSDT schema file as part of the build process. This gives you a real DB available at design time and in CI, without needing a full SQL Server instance.Option 2: DACPAC-based offline schema parsing (see #406)
@Thoriumpointed out that SQLProvider'sSsdt.DacpacParser.fs(at fsprojects/SQLProvider) can parse a DACPAC file without a live DB connection. Adapting this for FSharp.Data.SqlClient would allow the type provider to work entirely offline using schema metadata extracted from a DACPAC. This would be a significant feature addition.Option 3: Generated types (see #404)
A generated type provider would run once at build time, persist the generated code, and allow dependents to use it without a DB. This is the most ergonomic long-term solution but requires substantial design and implementation work.
Option 4: Schema metadata caching
As
@smoothdeveloperinvestigated: serialising the schema metadata to JSON works, but still requires the DB when SQL files change. This reduces but doesn't eliminate the DB dependency.If CI access to a DB is the main pain point, Option 1 with LocalDB is usually the most practical path. A minimal PowerShell or bash script that creates the LocalDB from your DACPAC's deploy script can be added as a CI step.