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>
Tow types of EF's default connection的更多相关文章
- EF 数据库连接约定(Connection String Conventions in Code First)
一个典型的EF应用大多数情况下是一个DbContext的派生类(derived class)来控制,通常可以使用该派生类调用DbContext的构造函数,来控制以下的东西: (1).上下文如何连接到数 ...
- python连接redis文档001
Installation redis-py requires a running Redis server. See Redis’s quickstart for installation instr ...
- Config File Settings Of EF——实体框架的配置文件设置
我亦MSDN 原文地址 http://msdn.microsoft.com/en-us/data/jj556606 Entity Framework allows a number of settin ...
- 自定义 ASP.NET Identity Data Model with EF
One of the first issues you will likely encounter when getting started with ASP.NET Identity centers ...
- EF 约定介绍
当前环境为EF Code First开发模式中 一.EF默认约定 1.常用约定 (1).当没有显示指定实体主键的时候,EF会默认将长得最像Id的属性(且类型为GUID)设为主键 (2).设计实体时,当 ...
- EntityFramework:EF Migrations Command Reference
Entity Framework Migrations are handled from the package manager console in Visual Studio. The usage ...
- Mongoose Connection best practice
There is often quite a lot of confusion about how best to set up a database connection with Mongoose ...
- SQL Server Connection Pooling (ADO.NET)
SQL Server Connection Pooling (ADO.NET) Connecting to a database server typically consists of severa ...
- [转]Oracle connection strings
本文转自:http://www.connectionstrings.com/oracle/ Standard Data Source=MyOracleDB;Integrated Security=ye ...
随机推荐
- Leetcode 814. Binary Tree Pruning
dfs 要点是这一句: return node.val==1 or node.left or node.right 完整代码: # Definition for a binary tree node. ...
- 重学CPP
LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt After install ...
- 为什么要重写toString()方法和hashcode()方法
一.toString(): 在Object类里面定义toString()方法的时候返回的对象的哈希code码,这个hashcode码不能简单明了的表示出对象的属性.所以要重写toString()方法. ...
- vc 编译器的一些精典报错
本篇将平时遇到的一些编译错误 , 记录于此 , 同时帖上分析
- C# 后台模拟前台post发送json数据
public static string PostMoths(string url, string param) { string strURL = url; System.Net.HttpWebRe ...
- BZOJ4974:[Lydsy1708月赛]字符串大师(逆模拟KMP)
题目描述 一个串T是S的循环节,当且仅当存在正整数k,使得S是T k Tk (即T重复k次)的前缀,比如abcd是abcdabcdab的循环节.给定一个长度为n的仅由小写字符构成的字符串S,请对于每 ...
- BZOJ1304 CQOI2009 叶子的染色 【树形DP】
BZOJ1304 CQOI2009 叶子的染色 Description 给一棵m个结点的无根树,你可以选择一个度数大于1的结点作为根,然后给一些结点(根.内部结点和叶子均可)着以黑色或白色.你的着色方 ...
- 使用python处理selenium中的获取元素属性问题
# 获取我的订单元素class属性值 at = self.driver.find_element_by_link_text('我的订单').get_attribute('class') # 判断cla ...
- 《DSP using MATLAB》示例Example 6.9
代码: % All-Pole IIR filter to Lattice structure filter a = [1, 13/24, 5/8, 1/3]; K = dir2latc(a) % To ...
- 《selenium2 python 自动化测试实战》(13)——上传文件
看代码: # coding: utf-8 from selenium import webdriver from time import sleep driver = webdriver.Firefo ...