Reputation: 8852
I'm using Entity Framework 4.1 Code First, Sqlite and WPF.
I want to redefine the app.config ConnectionString to sqlite, so I can define the Data Source (path for Sqlite database file) at runtime.
My guess is using the EntityConnectionStringBuilder to create the connection string. But I don't know what the event where I build and assign the connection string so the EF Code First will detect the change and will use the newer ConnectionString in all the code for the application (instead to use the app.config ConnectionString). I imagine that it's to be placed on Application_Startup event, but I don't know if this is the best pratice.
Thank you in advance.
Upvotes: 0
Views: 645
Reputation: 14302
If that's what you're after,
You can pass the string at runtime via DbContext(string)
constructor - see here for more DbContext(string)
You could also make your context implementation take that param and pass it to the base
DbContext.
hope this helps
Upvotes: 2
Reputation: 10865
IF you are using EF 4.1 CF, then once you do your *.edmx file generation it should create your app.config automatically. You don't need to create your own app.config or change it if you have an existing one.
Upvotes: 0