EF 4.1例外"提供者未返回ProviderManifestToken字符串" [英] EF 4.1 exception "The provider did not return a ProviderManifestToken string"
问题描述
我试图复制在MSDN上找到了一个例子。我使用ASP.NET和EF 4.1(CTP?)。我用的NuGet安装的EntityFramework包。
I am trying to replicate an example found on MSDN. I am using ASP.NET and EF 4.1 (CTP?). I've used NuGet to install the EntityFramework package.
我收到此错误:提供程序未返回一个字符串ProviderManifestToken
...
并且永远不会创建的数据库。
I am getting this error: The provider did not return a ProviderManifestToken string
...
and the database is never created.
下面是我的连接字符串:
Here is my connection string:
<add name="HospitalContext"
connectionString=
"data source=.\SQLExpress;initial catalog=NewTestDB;integrated security=True;"
providerName="System.Data.SqlClient"/>
下面是我的code:
var pat = new Patient { Name = "Shane123132524356436435234" };
db.Patients.Add(pat);
var labResult = new LabResult { Result = "bad", Patient = pat };
int recordAffected = db.SaveChanges();
下面是我的背景:
public class HospitalContext : DbContext
{
static HospitalContext()
{
Database.SetInitializer(new HostpitalContextInitializer());
}
public DbSet<Patient> Patients { get; set; }
public DbSet<LabResult> LabResults { get; set; }
}
public class HostpitalContextInitializer :
DropCreateDatabaseIfModelChanges<HospitalContext>
{
protected override void Seed(HospitalContext context)
{
context.Patients.Add(new Patient { Name = "Fred Peters" });
context.Patients.Add(new Patient { Name = "John Smith" });
context.Patients.Add(new Patient { Name = "Karen Fredricks" });
}
}
这是一个完全修补SQL 2008的系统,在VS 2010 SP1。
This is a fully patched SQL 2008 system, with VS 2010 SP1.
推荐答案
我得到这个错误,并尝试了一些早期的建议。然后,我检查了内部异常,发现我正在为用户一个简单的SQL登录失败。只是别的东西来检查。
I was getting this error and tried a few of the earlier suggestions. Then I checked the Inner Exception and noticed I was getting a simple SQL login failure for the user. Just something else to check.
这篇关于EF 4.1例外&QUOT;提供者未返回ProviderManifestToken字符串&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!