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. 自己手写一个SpringMVC框架

    前端框架很多,但没有一个框架称霸,后端框架现在Spring已经完成大一统.所以学习Spring是Java程序员的必修课. Spring框架对于Java后端程序员来说再熟悉不过了,以前只知道它用的反射实 ...

  2. 《PyQt5 快速开发与实战》 第九章代码Bug修正 DataGrid.py 最后一页下翻页 仍可点击的错误

    # -*- coding: utf-8 -*- import sys import re from PyQt5.QtWidgets import (QWidget , QHBoxLayout , QV ...

  3. Underscore template

    /********************************************************************* * Underscore template * 说明: * ...

  4. python中读取文件的f.seek()方法

    用于二进制文件中F.seek方法 作用: 设置读写位置 F.seek(偏移量, whence=相对位置) 偏移量 大于0的数代表向文件末尾方向移动的字节数 小于0的数代表向文件头方向中移动的字节数 相 ...

  5. Unity Obstacle分析

    NavMeshObstacle Normal 通过设置半径和高度来设定障碍物,配合NavMesh使用. 优点: 简单易用,效率高 动态生成 缺点: 可能会被主角穿过,但目前没发现 形状固定为圆柱 Na ...

  6. HDU1556 线扫

    昨天睡得太晚,今天又在看新算法,明天事情也多,烦,所以今天刷刷水题就过去了. 叫我用线段树,我反而搞不来 #include<cstdio> #include<cstdlib> ...

  7. Uoj 22 外星人

    Uoj 22 外星人 注意到一个数只有 \(\%\) 了小于等于自己的数时,才可能有变化,否则可以随意安排,不会对最后最优解造成影响. 用 \(f[x]\) 表示给一个数 \(x\) ,仅用 \(a[ ...

  8. SmartSql 动态仓储

    动态代理仓储 SmartSql源码:https://github.com/Ahoo-Wang/SmartSql 简介 动态代理仓储(SmartSql.DyRepository)组件是SmartSql非 ...

  9. python(七):元类与抽象基类

    一.实例创建 在创建实例时,调用__new__方法和__init__方法,这两个方法在没有定义时,是自动调用了object来实现的.python3默认创建的类是继承了object. class A(o ...

  10. uGUI知识点剖析之RectTransform

    http://www.2fz1.com/post/unity-ugui-recttransform/#jtss-tsina uGUI知识点剖析之RectTransform 一.基本要点 RectTra ...