[英]The provider did not return a ProviderManifestToken string - .NET MVC 3 #C
我正在学习使用.NET MVC 3和C#进行开发。 我正在尝试使用“Code First”方法来创建应用程序,但是当我尝试从数据库中提取数据时,我收到一条错误消息“提供程序未返回ProviderManifestToken字符串”。
我已经看过其他一些关于这个错误的帖子,但我找不到那些适合我的帖子的解决方案。
我在Windows 7 64位上使用MS Visual Web Developer Express 2010。 我正在使用SQL Compact Server 4.0作为我的数据库。
这段代码尝试运行时会触发错误:
public class StoreController : Controller
{
MusicStoreEntities storeDB = new MusicStoreEntities();
//
// GET: /Store/
public ActionResult Index()
{
var genres = storeDB.Genres.ToList(); // This line causes the error
return View(genres);
}
}
我的DbContext类如下:
public class MusicStoreEntities : DbContext
{
public DbSet<Album> Albums { get; set; }
public DbSet<Genre> Genres { get; set; }
}
我的连接字符串:
<connectionStrings>
<add name="MusicStoreEntities"
connectionString="Data Source=|DataDirectory|MvcMusicStore.sdf"
providerName="System.Data.SqlServerCe.4.0"/>
</connectionStrings>
有什么看起来不对吗? 如果您需要更多信息,请询问。
谢谢
你只需要把“。” 对于数据源中的localmachine,如下所示:
<add name="MYSQLSERVER" providerName="System.Data.SqlClient" connectionString="Data Source=.\\MYSQLSERVER;Trusted_Connection=true"></add>
</connectionStrings>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.