Reputation: 12142
The entity framework documentation states that I can use a named parameter when supplying my connection string:
public class BloggingContext : DbContext
{
public BloggingContext()
: base("name=BloggingCompactDatabase")
{
}
}
I normally don't normally bother with the named parameter:
public TspDbContext()
: base("ViktorVooey") { }
but I thought I'd give it a go just for confirmation:
public TspDbContext()
: base("name=ViktorVooey") { }
and it fails saying
Keyword not supported : name
This is on EF6. So I'm sort of stuck between not really caring but still wanting to know "what's up with that" all the same.
Upvotes: 1
Views: 2142
Reputation: 1646
I came across your post because I had the same error. The MSDN documentation for EF 6 DbContext explicitly states that the 'name=' part of the constructor string parameter is supported and means:
The name can also be passed in the form 'name=myname', in which case the name must be found in the config file or an exception will be thrown.
In other words the "name=" prefix forces EF to only look for a config file entry for the connection string.
So you should check that the value you pass with "name=" is actually a name key value in your config file.
For example, in the config file:
<add name="MyContextName" connectionString="blah blah"/>
In the constructor:
public MyContext()
: base("name=MyContextName")
Upvotes: 2
Reputation: 18188
For me this turned out to be an issue with Resharper. I suspended Resharper, built and the error went away.
After I restarted Resharper the error stayed away.
Upvotes: 0