【发布时间】:2018-01-24 01:29:38
【问题描述】:
我正在使用 Azure 函数创建我的第一个应用程序并尝试连接到本地 SQL Server Express 数据库。如何提供连接字符串,以便成功连接到本地 SQL Server Express 数据库?
当我尝试在本地运行应用程序时,出现以下错误:
发生 System.ArgumentException
HResult=0x80070057
消息=不支持关键字:“服务器”。
来源=堆栈跟踪:
在 System.Data.Entity.Core.EntityClient.Internal.DbConnectionOptions.ParseInternal(IDictionary
2 parsetable, String connectionString, IList1 validKeywords)
在 System.Data.Entity.Core.EntityClient.Internal.DbConnectionOptions..ctor(字符串连接字符串,IList1 validKeywords) at System.Data.Entity.Core.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) at System.Data.Entity.Core.EntityClient.EntityConnection..ctor(String connectionString) at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection) at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config) at System.Data.Entity.Internal.LazyInternalConnection.Initialize() at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName() at System.Data.Entity.Internal.LazyInternalContext.get_ProviderName() at System.Data.Entity.Internal.DefaultModelCacheKeyFactory.Create(DbContext context) at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) at System.Data.Entity.Internal.Linq.InternalSet1.Initialize() 在 System.Data.Entity.Internal.Linq.InternalSet1.GetEnumerator() at System.Data.Entity.Infrastructure.DbQuery1.System.Collections.Generic.IEnumerable.GetEnumerator() 在 System.Collections.Generic.List1..ctor(IEnumerable1 集合) 在 System.Linq.Enumerable.ToList[TSource](IEnumerable`1 源)
我的local.settings.json 看起来像这样:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "xxx",
"AzureWebJobsDashboard": "xxx"
},
"ConnectionStrings": {
"RecConnectionString": {
"ConnectionString": "Server=localhost\\SQLEXPRESS01;Database=myDB;Connection Timeout=30;Integrated Security=SSPI;",
"ProviderName": "System.Data.EntityClient"
}
},
"frameworks": {
"net46": {
"dependencies": {
"EntityFramework": "6.0.0",
"Newtonsoft.Json": "10.0.3"
}
}
}
}
【问题讨论】:
-
您使用的 SQL Express 版本是什么?
标签: sql-server entity-framework azure database-connection azure-functions