如何在IIS服务器上的配置中定义提供者名称?

时间:2018-07-06 21:46:47

标签: sql-server visual-studio iis configuration

我将Visual Studio中的项目和数据库SQL SERVER上传到IIS服务器。 配置:

LocalSqlServer:服务器= N-PC \ SQLEXPRESS;数据库=其余;集成安全性= true

RestEntities:“元数据= res:// /RestEntities.csdl|res:// /RestEntities.ssdl|res://*/RestEntities.msl;provider=System.Data.SqlClient ; provider connection string =“ data source = N-PC \ SQLEXPRESS; initial catalog = Rest; integrated security = True; MultipleActiveResultSets = True; App = EntityFramework”“ providerName =” System.Data.EntityClient“

我在IIS配置中看到的错误是: “ ExceptionMessage”:“应用程序的配置文件中的连接字符串'RestMarketEntities'不包含必需的providerName属性。\”“

  • 我是否需要在IIS服务器的“ providers”目录和“连接字符串”文件夹中设置PROVIDER NAME?

    • 我是否需要更改代码中的某些内容才能使其在IIS服务器上运行?
  • IIS中的连接字符串应该与代码中显示的完全相同吗?

谢谢

错误:

{

"Message": "An error has occurred.",

"ExceptionMessage": "The connection string 'RestEntities' in the application's configuration file does not contain the required providerName attribute.\"",

"ExceptionType": "System.InvalidOperationException",

"StackTrace": "   at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)\r\n   at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config)\r\n   at System.Data.Entity.Internal.LazyInternalConnection.Initialize()\r\n   at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()\r\n   at System.Data.Entity.Internal.DefaultModelCacheKeyFactory.Create(DbContext context)\r\n   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()\r\n   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)\r\n   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()\r\n   at System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator()\r\n   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n   at Rest.API.Controllers.CategoriesController.GetAll() in C:\\Users\\n\\VSProjects\\Rest.API\\Rest.API\\Controllers\\CategoriesController.cs:line 17\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"

0 个答案:

没有答案