我正在使用Entity Framework Code First 4.3+Azure,连接数据库遇到了困难。我在第一次查询时遇到了以下错误:
Keyword not supported: 'server'.
我在Web.config文件中设置了以下连接:
<configSections>
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<connectionStrings>
<add name="TestDBContext"
connectionString="Server=tcp:[SUBSCR].database.windows.net,1433;Database=[MyDB];User ID=[user];Password=[pass];Trusted_Connection=False;Encrypt=True;PersistSecurityInfo=True"
providerName="System.Data.EntityClient" />
</connectionStrings>
我的DbContext实现类使用连接字符串的名称:
public class MyContext : DbContext, IMyContext
{
public MyContext()
: base("TestDBContext")
{
Configuration.LazyLoadingEnabled = true;
Configuration.ProxyCreationEnabled = true;
}
你能告诉我发生了什么吗?
System.Data.SqlClient
而不是System.Data.EntityClient
。 - ryanmcdonnell