mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-03-05 13:40:55 +08:00
update
16
实体特性.md
16
实体特性.md
@@ -3,17 +3,16 @@ v1.4.0+ 已自动识别 EFCore 实体特性 Key/Required/NotMapped/MaxLength/Str
|
||||
|
||||
## 名称
|
||||
|
||||
FreeSql 默认使用实体的类名,或属性名与数据库映射,也可以指定映射的名称;
|
||||
|
||||
指定实体的表名 Name 后,实体类名变化不影响数据库对应的表。FreeSql尽量支持了对多数据库或schema支持,不防试试指定表名为:其他数据库.表名。
|
||||
|
||||
```csharp
|
||||
[Table(Name = "db2.tb_topic")]
|
||||
class Topic {
|
||||
[Table(Name = "tb_topic")]
|
||||
class Topic
|
||||
{
|
||||
//...
|
||||
}
|
||||
```
|
||||
|
||||
> 架构:[Table(Name = "dbo.tb_topic")]
|
||||
|
||||
> 注意:带点的表名,使用 [Table(Name = "\`sys.config\`")] 解决
|
||||
|
||||
> 指定表名的几种方法,优先级从小到大:
|
||||
@@ -24,11 +23,12 @@ class Topic {
|
||||
- 4、[Table(Name = "public.tabname")]
|
||||
- 5、AsTable fsql.Select<T>().AsTable((_, old) => "public.tabname").ToList()
|
||||
|
||||
修改表名,须指定旧的表名,CodeFirst才可以正确修改数据库表。
|
||||
修改表名,须指定旧的表名:
|
||||
|
||||
```csharp
|
||||
[Table(OldName = "Topic")]
|
||||
class Topic2 {
|
||||
class Topic2
|
||||
{
|
||||
//...
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user