Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SqlEntityConnection (Entity Data Model) TypeProvider

I am using the SqlEntityConnection (Entity Data Model) TypeProvider to connect to a SQL Server database that has a few tables and stored procedures.

#if INTERACTIVE
#r "System.Data"
#r "System.Data.Entity"
#r "FSharp.Data.TypeProviders"
#endif

open System.Data
open System.Data.Entity
open Microsoft.FSharp.Data.TypeProviders

// You can use Server Explorer to build your ConnectionString.
type internal SqlConnection = Microsoft.FSharp.Data.TypeProviders.SqlEntityConnection<ConnectionString = @"DataSource=server etc">
let internal db = SqlConnection.GetDataContext()

According to the documentation provided by a link in the template file - http://go.microsoft.com/fwlink/?LinkId=229210 "Get the data context, which is an object that contains the database tables as properties and the database stored procedures and functions as methods." db should have the stored procedures in the database as methods. However, I can only see the tables in the database as properties of db. What am I missing?

like image 335
user2484161 Avatar asked Aug 06 '26 01:08

user2484161


1 Answers

I think the documentation is incorrect. The SqlEntityConnection TP uses the tool edmgen.exe in the backend to do the actual codegen and heavy lifting, and from what I can tell that tool doesn't support including stored procedures as part of the generated proxy classes. Here's another SO question asking about exactly this, sadly no replies.

Running

edmgen.exe /mode:FullGeneration /connectionstring:"..." /language:CSharp /p:EdmTest

outputs various files, only one of which (the .ssdl file) contains any information about the stored procedures present in my DB.

The SqlDataConnection TP definitely does support stored procedures, in case that's a possible alternative for you.

like image 124
latkin Avatar answered Aug 08 '26 15:08

latkin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!