SqlEntityConnection Type Provider (F#)
Provides the types to access a database, using a LINQ to Entities mapping. This type provider is useful when you are using the ADO.NET Entity Model for a database.
Namespace/Module Path: Microsoft.FSharp.Data.TypeProviders
Assembly: FSharp.Data.TypeProviders (in FSharp.Data.TypeProviders.dll)
type SqlEntityConnection<?ConnectionString : string,
?ConnectionStringName : string
?LocalSchemaFile : string,
?Provider : string,
?EntityContainer : string,
?ConfigFile : string,
?DataDirectory : string,
?ResolutionFolder : string,
?ForceUpdate : bool,
?Pluralize : bool,
?SuppressForeignKeyProperties : bool>
Static Type Parameters
Type Parameter |
Description |
---|---|
?ConnectionString : string |
The connection string for the database connection. |
?ConnectionStringName : string |
The name of the connection string for the database connection in the configuration file. |
?LocalSchemaFile : string |
The path to a .csdl file that contains the schema. This parameter is often used with ForceUpdate set to true. |
?Provider : string |
The name of the ADO.NET data provider to be used. The default is System.Data.SqlClient. |
?EntityContainer : string |
The name to use for the generated type that represents the container for the entities, also known as the data context. The default value is EntityContainer. |
?ConfigFile : string |
The name of the configuration file that’s used for connection strings. The default value is app.config or web.config. |
?DataDirectory : string |
The name of the data directory that replaces |DataDirectory| in connection strings. The default value is the project or script directory. |
?Resolution Folder : string |
A folder to be used to resolve relative file paths at compile time. The default value is the folder that contains the project or script. |
?ForceUpdate : bool |
Determines whether the type provider updates the generated types to reflect changes in the database schema. When ForceUpdate is false, the provider reacts to changes in the LocalSchemaFile. The default value is true. |
?Pluralize : bool |
If true, uses plural forms for the generated type names. The default value is false. |
?SuppressForeignKeyProperties : bool |
Exclude foreign key properties in entity type definitions. The default value is false. |
Remarks
For a walkthrough that shows how to use this type provider, see Walkthrough: Accessing a SQL Database by Using Type Providers and Entities (F#).
The Entity Data Model Framework is a library for the .NET Framework that allows you to define a database schema largely independent of a specific data source (such as a SQL database). For more information, see ADO.NET Entity Framework and Entity Framework Overview. Database schemas that are represented by the Entity Data Model are encoded in a specific XML format in files with the .edmx extension.
The following table describes types generated by the SqlEntityConnection type provider for a declaration of the form:
type MyDb = SqlEntityConnection<parameters>
In the following table, EntityContainer is the single type generated by edmgen.exe, which has base type ObjectContext. This is the value of the static parameter EntityContainer, if it is given. Otherwise, it is the name chosen by edmgen.exe.
Type |
Description |
---|---|
MyDb |
The overall container type. Contains a method GetDataContext that returns a simplified view of the data context. The method returns a new instance of MyDB.ServiceTypes.SimpleDataContextTypes.EntityContainer. The version with the connectionString parameter may be used when the connection string is determined at runtime. |
MyDb.ServiceTypes |
Contains the embedded full types and simplified types for the database. |
MyDb.ServiceTypes.* |
The embedded types generated by EdmGen.exe. |
MyDb.ServiceTypes.EntityContainer |
The data context type, inherited from ObjectContext. |
MyDb.ServiceTypes.SimpleDataContextTypes.EntityContainer |
Contains one method for each method of the full context type, including stored procedures and functions. The methods return ISingleResult. Contains one property for each property of the full context type. The properties return Table. The property Connection gets the database connection as an instance of DbConnection. The property DataContext gets the full data context, of type ObjectContext. This is the base type of the EntityContainer type generated by the type provider. |
The Entity Data Model connection string that you specify at runtime when you call GetDataContext resembles the following:
metadata=res://*/entityNamespaceName.csdl|res://*/entityNamespaceName.ssdl|res://*/entityNamespaceName.msl;provider=provider;provider connection string="connectionString"
For more information about connection strings for the Entity Data Model, see Connection Strings
Platforms
Windows 8, Windows 7, Windows Server 2008 R2
Version Information
F# Core Library Versions
Supported in: 4.0
See Also
Tasks
Walkthrough: Accessing a SQL Database by Using Type Providers and Entities (F#)
Reference
Microsoft.FSharp.Data.TypeProviders Namespace (F#)