Monday, March 4, 2013

Keyword not supported: “data source” (Passing connection string of type EF to EF constructor)

Assuming you have a connection string that points to an Entity Framework object. And in your connection class, you pass the connection string to the Entity Framework constructor below:
customerEntity = new Database1Entities(_connectionString); 

You encountered an error Keyword not supported: "data source".

The solution is presented here: Keyword not supported data source initializing entity framework context

It suggests to replace the " word with single quote (') character.
So, in this case, I used Regex to perform replace operation.
 return Regex.Replace(ConfigurationManager.ConnectionStrings[key].ToString(),  
           @"&quot", "'", RegexOptions.IgnoreCase);


Post a Comment