实体框架defaultconnectionfactory [英] Entity Framework defaultconnectionfactory

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

问题描述

我最近使用实体框架4.3创建了一个新的Web项目。我正在使用数据库优先设计。

I've recently created a new web project using entity framework 4.3. I'm using database first design.

实体框架将此部分添加到了我的web.config中,它提供了一些参考性错误消息。我在某处读过该代码与代码优先设计有关-我需要它吗-我要删除它吗?

Entity Framework added this section to my web.config, which is giving some informational error messages. I've read somewhere that this code relates to code first design - do I need it - do I just remove it?

<entityFramework>
  <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
    <parameters>
      <parameter value="System.Data.SqlServerCe.4.0" />
    </parameters>
  </defaultConnectionFactory>
</entityFramework>

谢谢。

推荐答案

如果您不使用CodeFirst,我不确定100%是否重要(尝试将其删除,看看它是否运行正常)。但是,如果您使用CodeFirst并将SQLCE 4.0用作主数据库,则需要保留它。请参见文档

I am not 100% sure if it matters if you aren't using CodeFirst (try removing it and see if it runs ok). However, if you are using CodeFirst and using SQLCE 4.0 as your main database then you need to keep it. See the docs:


如果未设置默认连接工厂,则Code First使用SqlConnectionFactory指向.\SQLEXPRESS。 SqlConnectionFactory还具有一个构造函数,使您可以覆盖连接字符串的某些部分。如果要使用.\SQLEXPRESS以外的SQL Server实例,则可以使用此构造函数来设置服务器。

If you don’t set a default connection factory, Code First uses the SqlConnectionFactory, pointing to .\SQLEXPRESS. SqlConnectionFactory also has a constructor that allows you to override parts of the connection string. If you want to use a SQL Server instance other than .\SQLEXPRESS you can use this constructor to set the server.

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

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