实体框架 - 基础提供失败的ConnectionString的 [英] Entity Framework - The underlying provider failed on ConnectionString

查看:180
本文介绍了实体框架 - 基础提供失败的ConnectionString的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用实体框架我已经把它分解到它自己的项目:

While using the Entity Framework I have split it out to it's own project:


  • RivWorks.Model - 包含实体模型

  • RivWorks.Controller - 采用实体模型,并包含BIZ规则

  • RivWorks.View.Web - 该网站

  • RivWorks.View.Services - WCF项目

在网站中的一切工作正常。我能够调用到控制器,并得到一个有效的模式了。当我尝试从我收到此错误Web.Service同样的事情:

Everything in the web site is working fine. I am able to call into the Controller and get a valid Model back. When I try the same thing from the Web.Service I am getting this error:

错误:结果
  基础提供的ConnectionString的失败。结果
  堆栈跟踪:结果
    在System.Data.EntityClient.EntityConnection.ChangeConnectionString(字符串newConnectionString)结果
    在System.Data.EntityClient.EntityConnection..ctor(字符串的connectionString)结果
    在System.Data.Objects.ObjectContext.CreateEntityConnection(字符串的connectionString)结果
    在System.Data.Objects.ObjectContext..ctor(字符串的connectionString,字符串defaultContainerName)结果
    在RivWorks.Model.Entities.RivFeedsEntities1..ctor(字符串的connectionString)结果
    在RivWorks.Model.FeedStoreReadOnly..ctor(字符串的connectionString)结果
    在RivWorks.Controller.ProductManager.LookupProduct(字符串的productID,SKU字符串,字符串urlRef,ENV字符串,字符串LOGPATH)

ERROR:
The underlying provider failed on ConnectionString.
STACK TRACE:
at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
at System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString)
at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)
at RivWorks.Model.Entities.RivFeedsEntities1..ctor(String connectionString)
at RivWorks.Model.FeedStoreReadOnly..ctor(String connectionString)
at RivWorks.Controller.ProductManager.LookupProduct(String productID, String sku, String urlRef, String env, String logPath)

我有点困惑,通过错误日志,我终于想通了,没有被从Web站点的配置文件中读取连接字符串为什么和挖掘。所以,我添加了一些code赶上那和,就目前而言,很难codeD中的值一样:

I am a bit confused as to why and digging through the error logs I finally figured out the connection strings were not being read from the Web Site's config file. So, I added some code to catch that and, for now, hard coded the values in. Like:

public dataObjects.NegotiateSetup LookupProduct(string productID, string sku, string urlRef, string env, string logPath)
{
    string feedConnString = "";
    string rivConnString = "";

    log.InitializeLogFile(logPath);
    dataObjects.NegotiateSetup resultSet = new dataObjects.NegotiateSetup();

    try { feedConnString = AppSettings.FeedAutosEntities_connString; }
    catch { feedConnString = @"metadata=res://*/Entities.FeedEntities.csdl|res://*/Entities.FeedEntities.ssdl|res://*/Entities.FeedEntities.msl;provider=System.Data.SqlClient;provider connection string='Data Source=***.***.***.***;Initial Catalog=******;Persist Security Info=True;User ID=******;Password="******";MultipleActiveResultSets=True'"; }

    try { rivConnString = AppSettings.RivWorkEntities_connString; }
    catch { rivConnString = @"metadata=res://*/Entities.RivEntities.csdl|res://*/Entities.RivEntities.ssdl|res://*/Entities.RivEntities.msl;provider=System.Data.SqlClient;provider connection string='Data Source=******;Initial Catalog=******_Dev;Persist Security Info=True;User ID=******;Password="******";MultipleActiveResultSets=True'"; }

    try
    {
        using (RivFeedsEntities1 _dbFeed = new FeedStoreReadOnly(feedConnString).ReadOnlyEntities())
        {
            using (RivEntities _dbRiv = new RivWorksStore(rivConnString).NegotiationEntities())
            {

不过,很可惜,它仍然给我上面的错误!任何想法,为什么?

But, alas, it is still giving me the above error! Any ideas why?

推荐答案

我知道你一直在你的连接字符串碴周围消毒他们,但我猜你没有把&放; QUOT; 的围绕在密码

I know you've been mucking around with your connection strings to sanitize them but I'm guessing you didn't put the "'s around the password in?

他们是否实际需要?

这篇关于实体框架 - 基础提供失败的ConnectionString的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆