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

Can Poyrazoğlu picture Can Poyrazoğlu · Aug 9, 2011 · Viewed 162.2k times · Source

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?

Answer

Vaccano picture Vaccano · Aug 10, 2011

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.)