user2484161
user2484161

Reputation: 131

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?

Upvotes: 3

Views: 421

Answers (1)

latkin
latkin

Reputation: 16792

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.

Upvotes: 4

Related Questions