From ce7140783ee5706878b078f34150431416a5c468 Mon Sep 17 00:00:00 2001 From: 28810 <28810@YEXIANGQIN> Date: Fri, 28 Feb 2020 18:09:32 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BF=AE=E5=A4=8D=20EfFluentApi=20?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E5=8F=82=E6=95=B0=E7=B1=BB=E5=9E=8B=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FreeSql.Extensions.EfCoreFluentApi/EfCoreTableFluent.cs | 2 +- .../ICodeFirstExtensions.cs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Extensions/FreeSql.Extensions.EfCoreFluentApi/EfCoreTableFluent.cs b/Extensions/FreeSql.Extensions.EfCoreFluentApi/EfCoreTableFluent.cs index b914fbab..b9ab2cb2 100644 --- a/Extensions/FreeSql.Extensions.EfCoreFluentApi/EfCoreTableFluent.cs +++ b/Extensions/FreeSql.Extensions.EfCoreFluentApi/EfCoreTableFluent.cs @@ -271,7 +271,7 @@ namespace FreeSql.Extensions.EfCoreFluentApi _tf.ConfigEntity(eb2 => eb2.Navigate(_withOneProperty, _selfBind)); return this; } - public HasManyFluent HasForeignKey(Expression> foreignKey) + public HasManyFluent HasForeignKey(Expression> foreignKey) { if (foreignKey?.Body == null) throw new ArgumentException("参数错误 foreignKey 不能为 null"); var exp = foreignKey.Body; diff --git a/Extensions/FreeSql.Extensions.EfCoreFluentApi/ICodeFirstExtensions.cs b/Extensions/FreeSql.Extensions.EfCoreFluentApi/ICodeFirstExtensions.cs index bf2ff003..725da63a 100644 --- a/Extensions/FreeSql.Extensions.EfCoreFluentApi/ICodeFirstExtensions.cs +++ b/Extensions/FreeSql.Extensions.EfCoreFluentApi/ICodeFirstExtensions.cs @@ -36,6 +36,10 @@ namespace FreeSql.Extensions.EfCoreFluentApi //多对多 eb.HasMany(a => a.Tags).WithMany(a => a.Songs, typeof(Song_tag)); }); + cf.Entity(eb => + { + eb.HasMany(a => a.Songs).WithOne(a => a.Type).HasForeignKey( a => a.TypeId) + }); } public class SongType