我目前在一个带有 mvc4、web api、knout 和微风的单页应用程序中。使用微风调用 webapi。我可以直接调用我的 webapi。但是,当我从微风中调用它并尝试获取元数据时,它抛出了以下异常。我没有在项目中使用实体框架,所以使用带有实体的 DBSet 来提供 EFContextProvider。
public DbSet<TestModel> TestModels{ get; set; }
readonly EFContextProvider<TestProjectDbContext> tmContextProvider =
new EFContextProvider<TestProjectDbContext>();
[System.Web.Http.HttpGet]
public string Metadata()
{
try
{
return tmContextProvider.Metadata();
}
catch (Exception ex)
{
}
}
System.Configuration.ConfigurationErrorsException
TestProject.Controllers.TestProjectController - Metadata error message is - Failed to find or load the registered .Net Framework Data Provider.
source is -System.Data
stack trace is - at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
at System.Data.Entity.Infrastructure.SqlCeConnectionFactory.CreateConnection(String nameOrConnectionString)
at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.LazyInternalContext.get_CodeFirstModel()
at System.Data.Entity.Infrastructure.EdmxWriter.WriteEdmx(DbContext context, XmlWriter writer)
at Breeze.WebApi.EFContextProvider`1.GetCsdlFromDbContext(Object context)
at Breeze.WebApi.EFContextProvider`1.BuildJsonMetadata()
at Breeze.WebApi.ContextProvider.Metadata()
at TestProject.Controllers.TestProjectController.Metadata() in D:\TFS\TFS\MvcApplication3\Controllers\TestProjectController.cs:line 29
我的开发机器没有问题,但是当我尝试在另一台机器上部署它时,遇到了这个问题。