zoukankan      html  css  js  c++  java
  • Tow types of EF's default connection

    When you create a new project that makes use of Entity Framework 5, you'll notice how it uses LocalDb by default now. But let's assume you have a fully working instance of Sql Server that you wish to work against instead of LocalDb. How do you tell EF to use it? Simple, modify your application's config file. If you are running a web service or a website, your config file is web.config. If you are running a console application or a windows application, look for app.config.

    LocalDb

      <entityFramework>

        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">

          <parameters>

            <parameter value="v11.0" />

          </parameters>

        </defaultConnectionFactory>

      </entityFramework>

    Now, replace that portion of the configuration to make use of Sql Server instead of LocalDb.

    Sql Server

      <entityFramework>

        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">

          <parameters>

            <parameter value="Data Source=.; Integrated Security=True; MultipleActiveResultSets=True" />

          </parameters>

        </defaultConnectionFactory>

      </entityFramework>

  • 相关阅读:
    servlet中doGet()和doPost()的区别
    Hibernate 的getHibernateTemplate()方法使用
    c3p0 数据库连接池
    java 事务处理的概念
    hibernate 关联映射
    java 迭代器
    struts 值桟问题
    struts 属性驱动与模型驱动
    java 单例模式
    XML Node和Element
  • 原文地址:https://www.cnblogs.com/love-summer/p/3610498.html
Copyright © 2011-2022 走看看