在使用Entity Framework时,会注意到下面这句:

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{ modelBuilder.HasDefaultSchema("DEV");
.....
}

如果是sql server的话,写上dbo. 就行了

如果是oracle的话,写上“用户名”。

如果schema是用户的话,那为什么不叫HasDefaultUser呢? 非要叫个schema,弄的我都不知道怎么翻译它!

我们再来看,在数据迁移的过程生成的语句:

CreateTable(
"DEV.BackgroundJobs",
c => new
{
Id = c.Long(nullable: false, identity: true),
JobType = c.String(nullable: false, maxLength: ),
JobArgs = c.String(nullable: false),
TryCount = c.Short(nullable: false),
NextTryTime = c.DateTime(nullable: false),
LastTryTime = c.DateTime(),
IsAbandoned = c.Boolean(nullable: false),
Priority = c.Byte(nullable: false),
CreationTime = c.DateTime(nullable: false),
CreatorUserId = c.Long(),
})
.PrimaryKey(t => t.Id)
.Index(t => new { t.IsAbandoned, t.NextTryTime });

更加坚定了我的判断 ,schema就是用户名.

然而,经过一翻百度... 终于颠覆了我的认识。

DEV.BackgroundJobs。这里的DEV不是用户,是schema.

总的来看:

1. 用户user不是管理表的,user只是负责连接数据库的。别把它想的那么复杂。

2. schema是管理数据库对象的,当然包括表了,还有packages functions proceures等。

总结一句:

A USER may be given access to SCHEMA OBJECTS owned by different USERS. (https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6162110256950)

但这里也解释不了为什么user和schema会重名。

原来,当在数据库中创建了一个用户的时候,会自动创建一个同名的schema.

引用上文的话:

once you create a user in the database -- there is a schema. it is empty, but there is a schema. 

In fact, we have the concept of a schemaless user (user is stored outside the database, in an ldap respository for example). Here, there is no schema, not even the empty one. 

后面这句我选择忽略,很少用到。

所以最后用这位Tom大叔的话,做一个总结:他们是完全可相互替换使用

in oracle for all intents and purposes they are % interchangeable. 

Entity Framework 中 Schema是什么的更多相关文章

  1. Entity Framework 教程——Entity Framework中的实体类型

    Entity Framework中的实体类型 : 在之前的章节中我们介绍过从已有的数据库中创建EDM,它包含数据库中每个表所对应的实体.在EF 5.0/6.0中,存在POCO 实体和动态代理实体两种. ...

  2. 关于Entity Framework中的Attached报错相关解决方案的总结

    关于Entity Framework中的Attached报错的问题,我这里分为以下几种类型,每种类型我都给出相应的解决方案,希望能给大家带来一些的帮助,当然作为读者的您如果觉得有不同的意见或更好的方法 ...

  3. 关于Entity Framework中的Attached报错的完美解决方案终极版

    之前发表过一篇文章题为<关于Entity Framework中的Attached报错的完美解决方案>,那篇文章确实能解决单个实体在进行更新.删除时Attached的报错,注意我这里说的单个 ...

  4. [转]在Entity Framework中使用LINQ语句分页

    本文转自:http://diaosbook.com/Post/2012/9/21/linq-paging-in-entity-framework 我们知道,内存分页效率很低.并且,如果是WebForm ...

  5. 在Entity Framework中使用事务

    继续为想使用Entity Framework的朋友在前面探路,分享的东西虽然技术含量不高,但都是经过实践检验的. 在Entity Framework中使用事务很简单,将操作放在TransactionS ...

  6. Entity Framework中的多个库操作批量提交、事务处理

    在Entity Framework 中使用SaveChanges()是很频繁的,单次修改或删除数据后调用SaveChanges()返回影响记录数. 要使用批量修改或者批量删除数据,就需要SaveCha ...

  7. LinqToSql和ASP.NET Entity FrameWork 中使用事务

    ASP.NET Entity FrameWork中: int flag = -1; if (this.URPmanagementEntities1.Connection.State != System ...

  8. Lazy<T>在Entity Framework中的性能优化实践

    Lazy<T>在Entity Framework中的性能优化实践(附源码) 2013-10-27 18:12 by JustRun, 328 阅读, 4 评论, 收藏, 编辑 在使用EF的 ...

  9. Entity framework 中Where、First、Count等查询函数使用时要注意

    在.Net开发中,Entity framework是微软ORM架构的最佳官方工具.我们可以使用Lambda表达式在Entity framework中DbSet<T>类上直接做查询(比如使用 ...

随机推荐

  1. react 组件积累

    material-ui material-table ant-design https://ant.design/docs/react/getting-started-cn 定义组件(注意,组件的名称 ...

  2. Number Sequence---hdu1711(kmp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1711 题意就是求b数组在a数组出现的位置:就是kmp模板: #include<stdio.h&g ...

  3. Python的subprocess模块(一)

    原文连接:http://www.cnblogs.com/wang-yc/p/5624880.html 一.简介 subprocess最早在2.4版本引入.用来生成子进程,并可以通过管道连接他们的输入/ ...

  4. 12.Project Fields to Return from Query-官方文档摘录

    1 插入例句 db.inventory.insertMany( [ { item: "journal", status: "A", size: { h: 14, ...

  5. PCI 设备详解一

    2016-10-09 其实之前是简单学习过PCI设备的相关知识,但是总感觉 自己的理解很函数,很多东西说不清楚,正好今天接着写这篇文章自己重新梳理一下,文章想要分为三部分,首先介绍PCI设备硬件相关的 ...

  6. 解决MySQL ERROR 1130 (HY000): Host '192.168.31.115' is not allowed to connect to this MariaDB server

    # 给root用户授权 GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.31.115' IDENTIFIED BY 'root' WITH GRANT O ...

  7. (0)linux下的Mysql安装与基本使用(编译安装)

    一.大致操作步骤 环境介绍: OS:center OS6.5 mysql:5.6版本 1.关闭防火墙 查看防火墙状态:service iptables status 这样就意味着没有关闭. 运行以下命 ...

  8. java-mybaits-00601-查询缓存-一级缓存、二级缓存

    1.什么是查询缓存 mybatis提供查询缓存,用于减轻数据压力,提高数据库性能. mybaits提供一级缓存,和二级缓存. 一级缓存是SqlSession级别的缓存. 在操作数据库时需要构造 sql ...

  9. java 多线程 day15 CyclicBarrier 路障

    import java.util.concurrent.CyclicBarrier;import java.util.concurrent.ExecutorService;import java.ut ...

  10. CCoolBar 的替代方案 CDockablePane。

    (阅读受众需有一定MFC知识储备.) (技术支持:http://www.cnblogs.com/shuhaoc/archive/2011/06/26/cdockableform.html) 在以往很多 ...