Name: FSharp.EntityFramework.MicrosoftSqlServer
Owner: F# Community Project Incubation Space
Description: EntityFramework 7 DbContext scaffolding for SqlServer.
Created: 2015-12-20 17:45:02.0
Updated: 2016-11-29 11:49:59.0
Pushed: 2016-09-17 03:37:05.0
Size: 567
Language: F#
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
https://ef.readthedocs.org/en/latest/
EF7 ships with default CLI-based scaffolding. It works but F# developers can do better by leveraging unique design time mechamism called “Type Providers”.
Worth noting that type provider doesn't attempt to extend or alter EF7 runtime semantics - it's purely design time tool.
https://www.nuget.org/packages/FSharp.EntityFramework.MicrosoftSqlServer
FSharp.Data.Entity
AdventureWorks = SqlServer<"Data Source=.;Initial Catalog=AdventureWorks2014;Integrated Security=True", Pluralize = true>
db = new AdventureWorks()
nModelCreating <- fun modelBuilder ->
//override default model here
()
nConfiguring <- fun optionsBuilder ->
//do runtime configuration here: connection, transactoin etc.
optionsBuilder.UseSqlServer("Data Source=.;Initial Catalog=AdventureWorks2014;Integrated Security=True") |> ignore
y {
for x in db.``HumanResources.Shifts`` do
where (x.ShiftID > 1uy)
select x.Name
eq.iter (printfn "Shift: %s")
sert
newShift =
new AdventureWorks.``HumanResources.Shift``(
Name = "French coffee break",
StartTime = TimeSpan.FromHours 10.,
EndTime = TimeSpan.FromHours 12.,
ModifiedDate = DateTime.Now
)
change = db.``HumanResources.Shifts``.Add(newShift)
recordsAffrected = db.SaveChanges()
rt (recordsAffrected = 1)
rt(change.Entity.ShiftID > 0uy)