FreeSql 以 MIT 開源協(xié)議托管于 github:https://github.com/2881099/FreeSql
FreeSql 提供使用 Fluent Api, 在外部配置實體的數(shù)據(jù)庫特性,F(xiàn)luent Api 的方法命名與特性名保持一致,如下:
fsql.CodeFirst
.ConfigEntity<TestFluenttb1>(a => {
a.Name("xxdkdkdk1");
a.Property(b => b.Id).Name("Id22").IsIdentity(true);
a.Property(b => b.name).DbType("varchar(100)").IsNullable(true);
})
.ConfigEntity<TestFluenttb2>(a => {
a.Name("xxdkdkdk2");
a.Property(b => b.Id).Name("Id22").IsIdentity(true);
a.Property(b => b.name).DbType("varchar(100)").IsNullable(true);
});
//以下為實體類
class TestFluenttb1
{
public int Id { get; set; }
public string name { get; set; } = "defaultValue";
}
[Table(Name = "cccccdddwww")]
class TestFluenttb2
{
public int Id { get; set; }
public string name { get; set; } = "defaultValue";
}
fsql 是一個 IFreeSql 對象
參考:《實體特性說明》
優(yōu)先級
FluentApi < 實體特性
系列文章導航
(四)實體特性 Fluent Api