-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typeprovider not working when compiled with dotnet build #807
Comments
Also experiencing this on windows |
This is probably because Postgres driver is loaded via reflection and they have added dependency to a component, in this case Microsoft.Extensions.Logging.Abstractions.
|
I did both of these and it still doesn't work. Now, for the resolution path, do I want it pointing to the folder with Npgsql.dll? One that I installed with nuget? |
You have to point ResolutionPath to a folder where you have copied the reference dlls, so not only Npgsql.dll but also the missing (Microsoft.Extensions.Logging.Abstractions.dll). |
Yes, I have done this but it still doesn't work |
Which version of Npgsql started the issue? I guess 6.0.10 didn't had the issue? |
It doesn't matter what version of Npgsql I use. I have removed the resolution path for now because it wasn't making a difference. I can send a zip of the project if that would be helpful |
This is a different error. Another one was about dotnet.exe and Microsoft.Extensions.Logging.Abstraction.dll missing. This is about System.Runtime where it seems your VS is running on .NET Framework 4.7.2 and your references are .NET 6.0. |
Yes I'm getting different linting errors depending on using Visual Studio vs Jetbrains Rider. My program.fs file is targeting 8.0, and my references don't have anything about .NET framework. Would you be willing to send me a zip of a starter where this is working and just let me change the connection string? I have put the DLLs in a folder and set the resolution path but I can't for the life of me get it working. |
Ok, it seems there are multiple issues and all of them addressed now:
By addressing these issues, you should be able to run SQLProvider on your .NET 8.0 project with all the latest referencies. If you are interested of a working zip-file, having a readme.md how I made it, it's here: |
Thank you for this. I didn't realize the linter might not react when I change the resolutionPath. It requires an IDE restart, which made it unclear what I was doing was working. I ended up not needing anything except |
Describe the bug
In Vscode the typeprovider works with all necessary Entity's autocompleted from the database. but when you run
dotnet build
it fails to compile with following error./Users/afaayerhan/projects/rufworks/FsWebPlayground/DataCtx.fs(10,20): error FS3033: The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Could not create the connection, most likely this means that the connectionString is wrong. See error from Npgsql to troubleshoot: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. [/Users/afaayerhan/projects/rufworks/FsWebPlayground/FsWebPlayground.fsproj] /Users/afaayerhan/projects/rufworks/FsWebPlayground/DataCtx.fs(10,20): error FS3033: The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Could not create the connection, most likely this means that the connectionString is wrong. See error from Npgsql to troubleshoot: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. [/Users/afaayerhan/projects/rufworks/FsWebPlayground/FsWebPlayground.fsproj] /Users/afaayerhan/projects/rufworks/FsWebPlayground/DataCtx.fs(15,22): error FS0039: The type 'Object' does not define the field, constructor or member 'GetDataContext'. [/Users/afaayerhan/projects/rufworks/FsWebPlayground/FsWebPlayground.fsproj]
here is the code in DataCtx.fs file :
net6.0 true ` **To Reproduce** Steps to reproduce the behavior: use postgresql with similar code I posted before, replace with your own connection stringnamespace FsWebPlayground.DataCtx
fsharp open System open System.Linq open FSharp.Data.Sql module MyModule = let [<Literal>] dbVendor = Common.DatabaseProviderTypes.POSTGRESQL let [<Literal>] connString = "Username=postgres;Host=localhost;Database=payrolldb;Password=;Port=5432" let [<Literal>] owner = "public, identity" type SqlProv = SqlDataProvider< DatabaseVendor = Common.DatabaseProviderTypes.POSTGRESQL, ConnectionString = connString, Owner = owner > let dc = SqlProv.GetDataContext()
here is my fsproj:
`
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
![Screenshot 2023-11-23 at 18 04 59](https://private-user-images.githubusercontent.com/8157594/285273540-81568753-b51d-4f1e-ac7d-751f1c8ce9ac.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQzODc0NjUsIm5iZiI6MTcyNDM4NzE2NSwicGF0aCI6Ii84MTU3NTk0LzI4NTI3MzU0MC04MTU2ODc1My1iNTFkLTRmMWUtYWM3ZC03NTFmMWM4Y2U5YWMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjNUMDQyNjA1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MDJkYzJkYWQ3MWMxYTU5Nzg1YzAzNTNjYTdmZDY3N2E1NDQ5MTRjNzIyZDUzYzA1N2Y5NWQyMjA0ZjJlMWJjNCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.I3tdtU605zSoBbNatWV1GWXMDVpzBOXHBg2cnIqIaiY)
Deskstop (please complete the following information):
The text was updated successfully, but these errors were encountered: