Alex Rivera | Logout

EF 4.1 exception "The provider did not return a ProviderManifestToken string"

Asked 2011-03-24T17:45:39.753
88

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.

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"/>

Here is my code:

var pat = new Patient { Name = "Shane123132524356436435234" };
db.Patients.Add(pat);

var labResult = new LabResult { Result = "bad", Patient = pat };

int recordAffected = db.SaveChanges();

Here is my context:

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" });
    }
}

This is a fully patched SQL 2008 system, with VS 2010 SP1.

Edit
Report

1 Answer

1

In using Visual Studio 11 Beta with EF4.1 and ASP.NET MVC, I nearly pulled my hair out until I found

http://connect.microsoft.com/VisualStudio/feedback/details/740623/asp-net-mvc-4-default-connection-string-improperly-escaped

To fix my problem, I went into Application_Start and changed

Database.DefaultConnectionFactory = new SqlConnectionFactory("Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True");

to

Database.DefaultConnectionFactory = new SqlConnectionFactory(@"Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True");

answered 2012-05-14T22:56:27.260

Your Answer