Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

MVVM Entity Data Model. How to change EDM DB connection parameters at runtime

$
0
0

hi,

I created a MVVM project with a EntityDataModel (MyDataModel.edmx) and a related DataContext (MyDataContext), bound to a given DB schema. The resulting connection string in App.config is the following

<add name="MyDataContext" connectionString="metadata=res://*/MyDataModel.csdl|res://*/MyDataModel.ssdl|res://*/MyDataModel.msl;provider=Oracle.DataAccess.Client;provider connection string=&quot;DATA SOURCE=myDb;PASSWORD=pwd;PERSIST SECURITY INFO=True;USER ID=ADMIN&quot;"
      providerName="System.Data.EntityClient" />

now I have to write a Login form, which does not perform a simple "select from users" query, but instead, it has to connect the application entity to the corresponding DB schema. In other words, I wish to change the MyDataContext connection string, switching from ADMIN/pwd schema provided at design time, to User/password schema provided at runtime.

How can I do this?

thanks for your help


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>