Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 2个连接字符串,安全字符串起作用,实体框架不起作用';T_C#_Asp.net_.net_Entity Framework - Fatal编程技术网

C# 2个连接字符串,安全字符串起作用,实体框架不起作用';T

C# 2个连接字符串,安全字符串起作用,实体框架不起作用';T,c#,asp.net,.net,entity-framework,C#,Asp.net,.net,Entity Framework,我是ASP.NET新手,发现连接字符串很难掌握 我已经成功地连接了下面两个连接字符串,用于数据库安全的连接字符串工作正常,但是我无法让处理其余数据的主字符串工作。我认为这一定是因为连接字符串的实体框架元素 对于元数据部分,我使用了res://*/部分,因为我假设这效率较低,但如果我正确理解了我正在阅读的文档,那么它将涵盖所有内容 <remove name="ApplicationServices" /> <add name="ApplicationServices"

我是ASP.NET新手,发现连接字符串很难掌握

我已经成功地连接了下面两个连接字符串,用于数据库安全的连接字符串工作正常,但是我无法让处理其余数据的主字符串工作。我认为这一定是因为连接字符串的实体框架元素

对于元数据部分,我使用了
res://*/
部分,因为我假设这效率较低,但如果我正确理解了我正在阅读的文档,那么它将涵盖所有内容

<remove name="ApplicationServices" />
  <add name="ApplicationServices" 
     connectionString= "Server=184.168.194.64,1433;
     Database= myASPNETDB;
     User=****;
     Password=****;" 
     providerName="System.Data.SqlClient" />

 <remove name="PropManEntities" />
    <add name="PropManEntities" 
         connectionString="Metadata=res://*/;
                 provider=System.Data.SqlClient;
                 provider connection string='Data Source=184.168.194.64,1433;
         Initial Catalog=myTest_C;
                 User=****;
                 Password=****;
         multipleactiveresultsets=true'" 
                 providerName="System.Data.EntityClient" />
戈达迪不愿意在这件事上提供任何帮助

编辑:

在尝试Matteo的建议后,我得到了以下错误:

The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.]
   System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) +8425830
   System.Data.EntityClient.EntityConnection..ctor(String connectionString) +43
   System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString) +85
   System.Data.Objects.ObjectContext..ctor(String connectionString) +12
   System.Web.UI.WebControls.EntityDataSourceView.ConstructContext() +461
   System.Web.UI.WebControls.EntityDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +102
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +138
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30
   System.Web.UI.WebControls.DetailsView.DataBind() +4
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +105
   System.Web.UI.WebControls.DetailsView.EnsureDataBound() +223
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls()+75
   System.Web.UI.Control.EnsureChildControls() +83
   System.Web.UI.Control.PreRenderRecursiveInternal() +42
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)+974
试试这个

<add name="PropManEntities" connectionString="data source=184.168.194.64,1433;initial catalog=myTest_C;User Id=****;Password=****;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />

抱歉,我不知道您正在使用edmx文件。。 尝试此版本(而不是使用您的文件名):


如果这不起作用,我建议您添加一个新的edmx模型,并复制自动添加的连接字符串。 Matteo试试这个

<add name="PropManEntities" connectionString="data source=184.168.194.64,1433;initial catalog=myTest_C;User Id=****;Password=****;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />

抱歉,我不知道您正在使用edmx文件。。 尝试此版本(而不是使用您的文件名):


如果这不起作用,我建议您添加一个新的edmx模型,并复制自动添加的连接字符串。

Matteo

您是先使用代码还是从数据库生成.edmx?我认为Metadata=res://*/不起作用,如果起作用,请不要认为这真的很方便,因为如果您使用多个,例如来自其他程序集的模型,这将导致问题。尝试设置正确的.csdl、.ssdl和.msl(如果您不知道它必须是什么,请重新添加一个edmx并让它为您创建连接字符串)。我读对了吗,您的数据位于两个独立的数据库中?@Claies是的,没错,一个用于处理安全性的aspnetdb数据库,另一个用于主数据库。我不知道是否可以将两者结合起来。@MrBliz我已经从数据库生成了一个.edmx。您是先使用代码还是从数据库生成一个.edmx?我认为Metadata=res://*/不起作用,如果起作用,请不要认为这真的很方便,因为如果使用多个,例如来自其他程序集的模型,会导致问题。尝试设置正确的.csdl、.ssdl和.msl(如果您不知道它必须是什么,请重新添加一个edmx并让它为您创建连接字符串)。我读对了吗,您的数据位于两个独立的数据库中?@Claies是的,没错,一个用于处理安全性的aspnetdb数据库,另一个用于主数据库。我不知道是否可以将两者结合起来。@MrBliz我已经从数据库生成了一个.edmx。您是先使用代码还是从数据库生成一个.edmx?我认为Metadata=res://*/不起作用,如果起作用,请不要认为这真的很方便,因为如果使用多个,例如来自其他程序集的模型,会导致问题。尝试设置正确的.csdl、.ssdl和.msl(如果您不知道它必须是什么,请重新添加一个edmx并让它为您创建连接字符串)。我读对了吗,您的数据位于两个独立的数据库中?@Claies是的,没错,一个用于处理安全性的aspnetdb数据库,另一个用于主数据库。我不知道是否可以将两者结合起来。@MrBliz我已从数据库生成了一个.edmx。谢谢您的建议,请查看编辑后的问题,以了解我在尝试时收到的新错误消息。ThanksHi@Matteo我一直在试图理解连接字符串的.csdl、.ssdl和.msl files元素。我的印象是这些都包含在.edmx文件中。然而,当我编译我的项目时,我注意到包含.edmx文件的DAL目录不是编译元素之一。我需要尝试创建这些文件,还是需要更改连接字符串?感谢您的建议,请查看编辑后的问题,了解我在尝试时收到的新错误消息。ThanksHi@Matteo我一直在试图理解连接字符串的.csdl、.ssdl和.msl files元素。我的印象是这些都包含在.edmx文件中。然而,当我编译我的项目时,我注意到包含.edmx文件的DAL目录不是编译元素之一。我需要尝试创建这些文件,还是需要更改连接字符串?感谢您的建议,请查看编辑后的问题,了解我在尝试时收到的新错误消息。ThanksHi@Matteo我一直在试图理解连接字符串的.csdl、.ssdl和.msl files元素。我的印象是这些都包含在.edmx文件中。然而,当我编译我的项目时,我注意到包含.edmx文件的DAL目录不是编译元素之一。我需要尝试创建这些文件,还是需要更改连接字符串?
<add name="PropManEntities" connectionString="metadata=res://*/??????????.csdl|res://*/????????????.ssdl|res://*/???????????????.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=184.168.194.64,1433;initial catalog=MPInvoicingSystem;user id=*****;password=*****;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />