0
votes

I am writing an application on WPF (MVVM) using the Entity Framework (DataBase first). I want users to set the server name through interface, tell me how to do it please. If I pass the variable from the settings, I get a: System.ArgumentException keyword not supported 'data source'.

 using (var db = new PronetsDataBaseEntities(Properties.Settings.Default.ConnectionString)) { ...}

The ConnectionString is the same as it generated EntityFramework

(metadata=res://*/Data.PronetsDB.csdl|res://*/Data.PronetsDB.ssdl|res://*/Data.PronetsDB.msl;provider=System.Data.SqlClient;provider connection string="data source=DESKTOP-D6JRGFG\SQLEXPRESS;initial catalog=PronetsDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework")

Constructor on Entity:

public PronetsDataBaseEntities(string connectionString)
            : base(connectionString)
{
}
1

1 Answers

0
votes

The connection string must only be the part after "provider connection string=", so in your case: "data source=DESKTOP-D6JRGFG\SQLEXPRESS;initial catalog=PronetsDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"