今天使用WCF RIA做个Demo,但是发现服务器端写的方法总是不执行。这里,我使用的是LinqToEntitiesDomainService<ObjectContext>作为域服务类。通过Debug后发现其触发了ApplicationUnhandledException异常,里面的信息是:
Submit operation failed. The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.从这个信息中可以看出可能是配置文件的问题,后来查看web.config文件后才恍然大悟,原来是我忘记写ADO.NET 实体数据模型的数据库连接了,补上后问题解决。
例如:
<add name="DemoEntities" connectionString="metadata=res://*/Models.csdl|res://*/Models.ssdl|res://*/Models.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.;Initial Catalog=Demo;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
本文介绍了在使用WCFRIA创建Demo过程中遇到的服务器端方法不执行问题,并详细记录了解决该问题的过程。作者发现异常原因是由于配置文件中未设置正确的ADO.NET实体数据模型的数据库连接,最终通过补充配置解决了问题。

被折叠的 条评论
为什么被折叠?



