I'm building a Web API in F# to test some things out. I come from a C# background and I've structured things how I do there.
You can find the repo here: https://github.com/MrGodlike6/WebApiTest
I've referenced the WebApiTest.Repositories.SqlServer project in WebApiTest.WebApi but for some reason Visual studio says it can't find the WebApiTest.Repositories.SqlServer namespace.
The thing is that the solution compiles fine and I can run the application, it's just that I don't have IntelliSense for anything coming from the SqlServer project (e.g. in the CompositionRoot module).
I've tried a lot of things, from different DBs, to making a .NET Framework 4.7.2 project for the DB project. So far nothing works. Tried both Nuget & Paket and no difference. Tried VS 2019. In VS 2022 it gives some compile error that is unrelated.
I used dotPeek from JetBrains to look at the resulting .dll and the namespace & module are there as expected. Don't know what could be causing this.
Also can you indicate if the project/folder structure that I use is good for F#? Any other suggestions are also welcome.
EDIT: The SQL part is based of https://github.com/isaacabraham/get-programming-fsharp/tree/master/src/code-listings/lesson-35. Here everything works, although the SQL code is not put in a separate project.
I've commented the SqlEnumProvider and I no longer have problems in the composition root. I'll look a little closer at this provider and see if I can come up with something.
EDIT2: Created a issue on GitHub: https://github.com/fsprojects/FSharp.Data.SqlClient/issues/410
I've reproduced what you're seeing. The problem appears to be caused by a design-time error in the FSharp.Data type provider. In particular,
SqlEnumProvider
seems to be the source. When I remove theDbOperations
type from AccountRepository.fs (using plain strings instead of enum values), I'm able to get Intellisense forWebApiTest.Repositories.SqlServer
in CompositionRoot.fs.Here's my kludgy workaround:
I searched for an existing issue on GitHub, but didn't find one, so you might want to open a new one yourself.
If anyone else wants to try this, here's the dummy database schema I used to get things to compile: