.net 4.0 实体框架中出现异常:错误0194:已加载所有工件

.net 4.0 实体框架中出现异常:错误0194:已加载所有工件,.net-4.0,c#-4.0,entity-framework-4,.net 4.0,C# 4.0,Entity Framework 4,这是一个c#/asp.net项目。我得到的完整错误消息是:error 0194:加载到项集合中的所有工件必须具有相同的版本。遇到多个版本 该项目以3.5版开始,并升级到4.0版。当我尝试测试任何一种方法时,我会得到我在主题行中发布的错误。我将包括它抛出异常的实际行。如果人们有什么需要帮助的地方,请告诉我,我也会发布。任何帮助都将不胜感激,我在这方面运气不好 /// <summary> /// Initializes a new SFBExternalPaymentsEntities

这是一个c#/asp.net项目。我得到的完整错误消息是:error 0194:加载到项集合中的所有工件必须具有相同的版本。遇到多个版本

该项目以3.5版开始,并升级到4.0版。当我尝试测试任何一种方法时,我会得到我在主题行中发布的错误。我将包括它抛出异常的实际行。如果人们有什么需要帮助的地方,请告诉我,我也会发布。任何帮助都将不胜感激,我在这方面运气不好

/// <summary>
/// Initializes a new SFBExternalPaymentsEntities object using the connection string found in the 'SFBExternalPaymentsEntities' section of the application configuration file.
/// </summary>    
public SFBExternalPaymentsEntities() : base("name=SFBExternalPaymentsEntities", "SFBExternalPaymentsEntities")     
{
    this.ContextOptions.LazyLoadingEnabled = false;     
    OnContextCreated();    
}

/// <summary>    
/// Initialize a new SFBExternalPaymentsEntities object.
/// </summary>
public SFBExternalPaymentsEntities(string connectionString) : base(connectionString, "SFBExternalPaymentsEntities")     
{
    this.ContextOptions.LazyLoadingEnabled = false;    
    OnContextCreated();    
}

/// <summary>
/// Initialize a new SFBExternalPaymentsEntities object.
/// </summary>
public SFBExternalPaymentsEntities(EntityConnection connection) : base(connection, "SFBExternalPaymentsEntities")     
{
    this.ContextOptions.LazyLoadingEnabled = false;     
    OnContextCreated();    
}
#endregion

您刚刚将构造函数发布到SFBExternalPaymentSenties类,但您似乎说,当您调用一个返回实体集合的方法时,会出现一个异常,该方法会使用您获得的异常消息进行发送。问题可能存在于您正在调用的方法中,或者存在于调用它的代码中,而不是存在于您发布的构造函数代码中。您能否发布一些更相关的代码或解释您发布的代码与异常的关系。

当我将一个项目从.net 4.0更新到4.5时,遇到了相同的问题,原因可能是因为目标项目中引用了另一个项目中的另一个.edmx文件。 问题解决方案:将引用并包含.edmx文件的其他项目更新为.net 4.5,然后右键单击这两个项目中的每个.edmx文件,然后选择“运行自定义工具”
它对我有用,希望它对阅读本文的每个人都有用本杰明,谢谢你的回复。我尝试了几种方法,它们都给出了相同的错误,但我会发布其中一种方法,以防我走错了方向。我正在为下一条评论添加一些代码。它太长,无法包含在此处。>公共静态CreditCardResponse AuthCapture(CreditCard newCC){ACHResponse validateResponse=CreditCard.Validate(newCC);if(validateResponse.Status==“Accepted”){Profile currentProfile=new Profile();currentProfile=ProfilesGateWay.GetByID(newCC.ProfileID);CreditCardTransaction newCCTransaction=CreateCreditCardTransaction(newCC,currentProfile);最后一行是它命中构造函数并消失的地方。Ben,我刚刚将该方法添加到原始发布中。对不起,第一次在这里发布,不熟悉界面。谢谢查看。
public static CreditCardResponse AuthCapture(CreditCard newCC)
{
    ACHResponse validateResponse = CreditCard.Validate(newCC);
    if (validateResponse.Status == "Accepted")
    {
        Profile currentProfile = new Profile();
        currentProfile = ProfilesGateWay.GetByID(newCC.ProfileID);
        CreditCardTransaction newCCTransaction = CreateCreditCardTransaction(newCC, currentProfile);
        ServiceClient client = new ServiceClient();
        CreditCardTransactionResponse cctResponse = client.CreditCardAuthorizeAndCapture(newCCTransaction);
        client.Close();
        CreditCardResponse ccResponse = CreateCCResponse(cctResponse);

        if (ccResponse.ResponseCode == 1)
        {
            int authAVS = ConvertAVStoInt(ccResponse.AVSResponse);
            int appAVS = ConvertAVStoInt(newCC.AVLevel);
            bool isAVSPass = CompareAVS(authAVS, appAVS);

            if (isAVSPass == false)
            {
                ccResponse.ResponseCode = 0;
                ccResponse.ResponseReasonCode = 99;
                ccResponse.ResponseText = "Did not meet your AVS requirements";
                return ccResponse;
            }
                else
                {

                 int newCCID =  CreateCreditCardRecord(newCC, currentProfile, cctResponse, "Captured", "Auth_Capture");
                CreditCardRecord updateCC = CreditCardRecordsGateWay.GetByID(newCCID);
                updateCC.CaptureOn = DateTime.Now;
                CreditCardRecordsGateWay.Update(updateCC);
                return ccResponse;
                }
            }
        else
        {
            return ccResponse;
        }

     }
    CreditCardResponse newCCResponse = new CreditCardResponse();
    newCCResponse.ResponseCode = 0;
    newCCResponse.AchResponse = validateResponse;
   return newCCResponse;
}
public static CreditCardResponse PriorAuthCapture(CreditCard newCC)
{
    CreditCardRecord ccRecord = CreditCardRecordsGateWay.GetByCCGateWayID(newCC.CreditCardTransactionID);
    ServiceClient client = new ServiceClient();
    CreditCardTransaction ccTransaction = client.CreditCardGetTransactionById(ccRecord.CCGatewayID);
    CreditCardTransactionResponse cctResponse = client.CreditCardPriorAuthorizationCapture(ccTransaction);
    if (cctResponse.ResponseCode == 1)
    {
        ccRecord.Status = "Captured";
        ccRecord.CaptureOn = DateTime.Now;
    }

    CreditCardResponse ccResponse = CreateCCResponse(cctResponse);
    return ccResponse;
}
protected static int CreateCreditCardRecord(CreditCard newCC, Profile currentProfile, CreditCardTransactionResponse cctResponse, string status, string transactionType)
{
    CreditCardRecord newCCRecord = new CreditCardRecord();
    newCCRecord.Address = newCC.Address;
    newCCRecord.AddressVerificationLevel = newCC.AVLevel;
    newCCRecord.Amount = newCC.Amount;
    newCCRecord.CardCode = newCC.CardCode;
    newCCRecord.CardNumber = newCC.CardNumber;
    newCCRecord.CCGatewayID = cctResponse.CreditCardTransactionID;
    newCCRecord.City = newCC.City;
    newCCRecord.CompanyName = newCC.CompanyName;
    newCCRecord.CreateBy = currentProfile.ACHCompanyName;
    newCCRecord.CreateOn = DateTime.Now;
    newCCRecord.Description = newCC.Description;
    newCCRecord.Expiration = newCC.Expiration;
    newCCRecord.FirstName = newCC.FirstName;
    newCCRecord.LastName = newCC.LastName;
    newCCRecord.Profile.ProfileID = currentProfile.ProfileID;
    newCCRecord.State = newCC.State;
    newCCRecord.Status = status;
    newCCRecord.TransactionType = transactionType;
    newCCRecord.Zip = newCC.Zip;
    return CreditCardRecordsGateWay.Insert(newCCRecord);
}