Keyword not supported: "data source" initializing Entity Framework Context

Entity FrameworkConnection String

Entity Framework Problem Overview


I'm initializing Entity Framework Object context, and this gives me the keyword not supported error:

metadata=res://*/MainDB.csdl|res://*/MainDB.ssdl|res://*/MainDB.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Workspace\vs\Leftouch\Leftouch.Web\Data\Leftouch.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True;App=EntityFramework"

I took the connection string directly from web.config which was working, and modified only the path to the file (which I set dynamically), and instead of using the default value, used this connection string explicitly. What could cause this error?

Entity Framework Solutions


Solution 1 - Entity Framework

The real reason you were getting this error is because of the " values in your connection string.

If you replace those with single quotes then it will work fine.

https://docs.microsoft.com/archive/blogs/rickandy/explicit-connection-string-for-ef

(Posted so others can get the fix faster than I did.)

Solution 2 - Entity Framework

I fixed this by changing EntityClient back to SqlClient, even though I was using Entity Framework.

So my complete connection string was in the format:

<add name="DefaultConnection" connectionString="Data Source=localhost;Initial Catalog=xxx;Persist Security Info=True;User ID=xxx;Password=xxx" providerName="System.Data.SqlClient" />

Solution 3 - Entity Framework

This appears to be missing the providerName="System.Data.EntityClient" bit. Sure you got the whole thing?

Solution 4 - Entity Framework

Believe it or not, renaming LinqPad.exe.config to LinqPad.config solved this problem.

Solution 5 - Entity Framework

Make sure you have Data Source and not DataSource in your connection string. The space is important. Trust me. I'm an idiot.

Solution 6 - Entity Framework

Just use " instead ", it should resolve the issue.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCan PoyrazoğluView Question on Stackoverflow
Solution 1 - Entity FrameworkVaccanoView Answer on Stackoverflow
Solution 2 - Entity FrameworkSavageView Answer on Stackoverflow
Solution 3 - Entity FrameworkCraig StuntzView Answer on Stackoverflow
Solution 4 - Entity FrameworkSameer AlibhaiView Answer on Stackoverflow
Solution 5 - Entity FrameworkHairgami_MasterView Answer on Stackoverflow
Solution 6 - Entity FrameworkNilesh MoradiyaView Answer on Stackoverflow