0

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 Answer 1

0

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"

Sign up to request clarification or add additional context in comments.

3 Comments

I tried it before this I ask. This is not work. System.Data.Entity.Infrastructure.UnintentionalCodeFirstException: The context is used in Code First mode with code generated from an .edmx file for developing Database First or Model First.
did you omit the quotation marks in the string itself?
Thanks, I solved the problem of creating my connection method

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.