找不到实体框架提供商 [英] No Entity Framework provider found

查看:59
本文介绍了找不到实体框架提供商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获取

没有为ADO.NET提供程序找到具有不变名称System.Data.SqlServerCe.4.0的实体框架提供程序。确保提供程序已在应用程序配置文件的entityFramework部分中注册。



 <   connectionStrings  >  
< add name = ComicContextDb < span class =code-attribute> connectionString = 数据源= | DataDirectory | \Database1。 sdf providerName = System.Data.SqlServerCe.4.0 / >
< entityFramework >
< defaultConnectionFactory type = System.Data.Entity.Infrastructure.SqlConnectionFactory,EntityFramework / >
< 提供商 >
< 提供商 invariantName = System.Data.SqlClient type = System.Data.Entity.SqlServer .SqlProviderServices,EntityFramework.SqlServer / >
< / providers >
controller.cs

private ComicContext database = new ComicContext(ComicContextDb);
[HttpPost]
public ActionResult RSVPForm(GuestResponse from)
{
database.Database1.Add(from);
database.SaveChanges();
返回内容(新漫画添加。);
}

解决方案

嗨Karthik,





您的计算机上是否安装了实体框架?

通过安装SQL Server精简版可以解决此问题。

您可以从http下载它: //www.microsoft.com/en-in/download/details.aspx?id=17876



更新的解决方案:



您是否为表定义了ID,默认情况下每个表都应具有主键ID。只需将ID元素添加到类文件中,实体框架将默认将ID视为主键。



希望这对你有所帮助



问候,

RK

Am getting
No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0'. Make sure the provider is registered in the 'entityFramework' section of the application config file.

<connectionStrings>
 <add name="ComicContextDb" connectionString="Data Source=|DataDirectory|\Database1.sdf" providerName="System.Data.SqlServerCe.4.0"/>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
controller.cs

        private ComicContext database = new ComicContext("ComicContextDb");
    [HttpPost]
    public ActionResult RSVPForm(GuestResponse from)
    {
        database.Database1.Add(from);
        database.SaveChanges();
        return Content("New comic added.");
    }

解决方案

Hi Karthik,


Do you have entity framework installed on your machine?
By installing SQL Server compact edition would resolve this issue.
You can download it from http://www.microsoft.com/en-in/download/details.aspx?id=17876

Updated solution:

Have you defined ID for the table, by default every table should have primary key ID.Just add ID element to the class file, entity framework will consider ID as primary key by default.

Hope this helps you a bit

Regards,
RK


这篇关于找不到实体框架提供商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆