I am trying to make SQLite work with EF6 and F3 using System.Data.Sqlite.
I am following walkthrough described here and got edmx file and C# program to compile (I've done that before). Walkthrough: Generating F# Types from an EDMX Schema File (F#)
Default code shown no errors during the design time and table structure is picked up by VS. Basically, edmx file is ok.
type internal edmx = EdmxFile<"ModelK.edmx">
[<EntryPoint>]
let main argv =
let context = new edmx.MyBaseModel.MyBaseEntities(strBulder)
query { for course in context.T1 do
select course.r1 }
|> Seq.iter (fun course -> printfn "%s" course)
printfn "%A" argv
0 // return an integer exit code
I am using NuGet package System.Data.SQLite EF6 1.0.94.0, deps EntityFramework 6.1.1, System.Data.SQLite Core 1.0.94.0 and have bundle installed from SQLite side (one with VS2013 support).
My problem is sql connecion string. EF requires connection string with meta and the regular sting doesn't work.
This is my original connection string from designer.
@"metadata=http://res*/ModelK.csdl|res*/ModelK.ssdl|res*/ModelK.msl;provider=System.Data.SQLite.EF6;provider connection string="data source=D:\VS2013\FSharp940\FSharp940MyBase.db"" providerName="System.Data.EntityClient""
What I've tried so far:
- Passing escaped (" to make a valid string and some other escape seqs) to MyBaseEntities(strBulder).
System.ArgumentException was unhandled Message: An unhandled exception of type 'System.ArgumentException' occurred in System.Data.Entity.dll Additional information: keyword not supported: data source.
Followed some SO advice and replaced " with '. Got Error reading schema, must start with / and be divided by :.
The type provider 'Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders' reported an error: Error reading schema. fel 7005: Parametern source=D:\VS2013\FSharp940\FSharp940\MyBase.db har angetts p† ett felaktigt s„tt. Alla v„xlar m†ste b”rja med tecknet / och namnet m†ste avgr„nsas fr†n v„rdet med kolon ':'.
Taken my C# App.Config entity connection strings and other things to my F# App.Config and reading from there.
type internal FooDb = SqlEntityConnection<ConnectionStringName="MyBaseEntities", ConfigFile="App.config">
Nope.
The type provider 'Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders' reported an error: Error reading schema. fel 7005: Parametern source=D:\VS2013\FSharp940\FSharp940\MyBase.db
I do understand that it is complaining about filepath and done some experiments with it without any results
The type provider 'Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders' reported an error: Error reading schema. fel 7001: keywork st”ds not: metadata.
Finally I tried EntityConnectionStringBuilder.
let strBulder =
let conn = new EntityConnectionStringBuilder()
conn.Metadata <- @"http://res*/ModelK.csdl|res*/ModelK.ssdl|res*/ModelK.msl;"
conn.Provider <- @"System.Data.EntityClient"
conn.ConnectionString <- @"D:\VS2013\FSharp940\FSharp940\MyBase.db"
let ec = new EntityConnection(conn.ToString())
ec
New one...
An unhandled exception of type 'System.TypeInitializationException' occurred in Unknown Module.
Everything I write to conn.ConnectionString throws an exception, including MyBase.db without any path.
I see that the problem is in connection string and probably my filepath, but at the moment have no idea what the correct format is. I mean... EF must understand it's own config file, right?
Any ideas? :)
Aucun commentaire:
Enregistrer un commentaire