【问题标题】:The provider did not return a ProviderManifestToken string - .NET MVC 3 #C提供者未返回 ProviderManifestToken 字符串 - .NET MVC 3 #C
【发布时间】:2012-08-08 21:02:44
【问题描述】:

我正在学习使用 .NET MVC 3 和 C# 进行开发。我正在尝试使用“代码优先”方法来创建应用程序,但是当我尝试从数据库中提取数据时,我收到一条错误消息“提供程序没有返回 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>

有什么看起来不对的地方吗?如果您需要更多信息,请询问。

谢谢

【问题讨论】:

    标签: c# asp.net asp.net-mvc-3 sql-server-ce


    【解决方案1】:

    你只需要输入“。”对于数据源中的localmachine如下:

    <add name="MYSQLSERVER" providerName="System.Data.SqlClient" connectionString="Data Source=.\MYSQLSERVER;Trusted_Connection=true"></add>
    </connectionStrings>

    【讨论】:

      猜你喜欢
      • 2016-04-04
      • 1970-01-01
      • 2013-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-22
      • 2019-05-25
      • 1970-01-01
      相关资源
      最近更新 更多