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>

Tow types of EF's default connection的更多相关文章

  1. EF 数据库连接约定(Connection String Conventions in Code First)

    一个典型的EF应用大多数情况下是一个DbContext的派生类(derived class)来控制,通常可以使用该派生类调用DbContext的构造函数,来控制以下的东西: (1).上下文如何连接到数 ...

  2. python连接redis文档001

    Installation redis-py requires a running Redis server. See Redis’s quickstart for installation instr ...

  3. Config File Settings Of EF——实体框架的配置文件设置

    我亦MSDN 原文地址 http://msdn.microsoft.com/en-us/data/jj556606 Entity Framework allows a number of settin ...

  4. 自定义 ASP.NET Identity Data Model with EF

    One of the first issues you will likely encounter when getting started with ASP.NET Identity centers ...

  5. EF 约定介绍

    当前环境为EF Code First开发模式中 一.EF默认约定 1.常用约定 (1).当没有显示指定实体主键的时候,EF会默认将长得最像Id的属性(且类型为GUID)设为主键 (2).设计实体时,当 ...

  6. EntityFramework:EF Migrations Command Reference

    Entity Framework Migrations are handled from the package manager console in Visual Studio. The usage ...

  7. Mongoose Connection best practice

    There is often quite a lot of confusion about how best to set up a database connection with Mongoose ...

  8. SQL Server Connection Pooling (ADO.NET)

    SQL Server Connection Pooling (ADO.NET) Connecting to a database server typically consists of severa ...

  9. [转]Oracle connection strings

    本文转自:http://www.connectionstrings.com/oracle/ Standard Data Source=MyOracleDB;Integrated Security=ye ...

随机推荐

  1. 十图详解TensorFlow数据读取机制(附代码)

    在学习TensorFlow的过程中,有很多小伙伴反映读取数据这一块很难理解.确实这一块官方的教程比较简略,网上也找不到什么合适的学习材料.今天这篇文章就以图片的形式,用最简单的语言,为大家详细解释一下 ...

  2. D3.js 使用心得

    教程 D3.js 入门教程系列 http://www.ourd3js.com/wordpress/296/ 全球地图数据

  3. 关于python的包

    参考文献:http://blog.sina.com.cn/s/blog_615c388d01017b5o.html 注:本文大多对上连接的整理,仅用于学习,望博主见谅.转载请附上上述链接. 为什么要包 ...

  4. Nodejs下express+ejs模板的搭建

    nodejs的环境配置,这里就不做说明了.在nodejs安装后的步骤在这里说明一下 首先 全局安装express  npm install -g express-generator 安装ok后,接着 ...

  5. 框架重构:测试中的DateTime.Now

    存在的问题 DateTime.Now是C#语言中获取计算机的当前时间的代码: 但是,在对使用了DateTime.Now的方法进行测试时,由于计算机时间的实时性,期望值一直在变化.如:计算年龄. pub ...

  6. [译]SSL/TLS真的被BEAST攻击攻破了吗?真实情况是怎样的?我应该做什么?

    原文链接:https://luxsci.com/blog/is-ssltls-really-broken-by-the-beast-attack-what-is-the-real-story-what ...

  7. erl_0017 《硝烟中的erlang》 读书笔记004 “锁和阻塞”

    如果某个进程需要持续地接收新任务,那么其在执行耗时过长的锁或者阻塞操作时,就会出现问题. 最为常见的例子之一就是:某个进程使用了TCP socket,阻塞在了接收新的连接或者等待消息上面.在执行此类阻 ...

  8. ssm异常;

    问题:Invalid bound statement (not found): com.itq.mapper.TbItemMapper.selectByExample 解决:修改pom.xml文件中添 ...

  9. Flask第五篇——设置debug模式

    flask默认是没有开启debug模式的,开启debug模式有很多好处: 第一,可以帮助我们查找代码里面的错误,比如: # coding: utf-8 from flask import Flask ...

  10. 【DUBBO】Dubbo原理解析-Dubbo内核实现之SPI简单介绍

    Dubbo采用微内核+ 插件体系,使得设计优雅,扩展性强.那所谓的微内核+插件体系是如何实现的呢!大家是否熟悉spi(service providerinterface)机制,即我们定义了服务接口标准 ...