我使用Code First。一切正常(插入,更新,選擇)一切都經過測試。我嘗試使用Web服務時出現問題。我收到錯誤「System.Data.ProviderIncompatibleException:提供程序沒有返回ProviderManifestToken字符串」。看看內部異常,我收到了這條消息:「無法確定存儲版本;需要有效的存儲連接或版本提示。」在Web服務中使用Code First時出錯「System.Data.ProviderIncompatibleException:提供程序未返回ProviderManifestToken字符串」。
Web服務代碼:
/// <summary>
/// Summary description for UserServices
/// </summary>
[WebService(Namespace = "http://localhost:3955/WebServices/UserServices")]
//[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class UserServices : System.Web.Services.WebService
{
[WebMethod]
public bool LoginControlPanelUser(string user, string password)
{
if(Membership.ValidateUser(user, password))
{
return DbUsersDAO.HasAuthenticationType(user, password);
}
return false;
}
}
的DAO代碼:
public static bool HasAuthenticationType(string user, string authenticationTypeCode)
{
try
{
using (VirtusCloudCoreContext ctx = new VirtusCloudCoreContext())
{
DBUser User = ctx.DBUsers.SingleOrDefault(u => u.Login.Equals(user) && u.Active.Equals(true));
if (User != null)
{
return DBAuthenticationTypesDAO.GetById(User.DBAuthenticationTypeId).Name.Equals("Admin");
}
}
return false;
}
catch (Exception ex)
{
ErrorsHelper.InsertError(ex);
throw ex;
}
}
上下文類:
public VirtusCloudCoreContext()
{
Database.SetInitializer<VirtusCloudCoreContext>(new VirtusCloudCoreContextInitializer());
this.Database.Connection.ConnectionString = "Data Source=localhost\SQLEXPRESS;Database=DatabaseName;User Id=******;Password=*******;" ;
}
我得到的異常當我嘗試獲取用戶。 ... 有任何想法嗎?
這對我有用,我使用VS2013。 – wilsjd 2014-07-09 18:30:44