WCF RIA方法无效的一种解决方法

来源:互联网 发布:网络直播行业研究报告 编辑:程序博客网 时间:2024/05/17 04:56

  今天使用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" />

原创粉丝点击