C# 检测fluent API的使用

C# 检测fluent API的使用,c#,entity-framework,fluent-interface,C#,Entity Framework,Fluent Interface,假设我有以下数据模型: public class Base { public int Id { get; set; } public string Name { get; set; } } 以及以下有关模型创建的信息: 实体框架的fluent API的使用是否可以在编译时或运行时检测到?在伪代码中,我希望执行以下操作: for a given Base detect that Name is required and must be <= 32 character

假设我有以下数据模型:

public class Base {
    public int Id { get; set; }
    public string Name { get; set; }
}
以及以下有关模型创建的信息:

实体框架的fluent API的使用是否可以在编译时或运行时检测到?在伪代码中,我希望执行以下操作:

for a given Base
    detect that Name is required and must be <= 32 characters
    act upon that information 

对于上下文,我试图生成符合数据注释或fluentapi对其施加的限制的伪随机poco。数据注释非常简单,但我还没有找到一种方法来处理fluentapi的使用

好吧,你必须深入到EF的元数据中去,但老实说,我不知道你想做什么。我希望能够调用一些方法Gen,并获得一个通过EF的SaveChanges成功保存的基本对象。我会调查你提到的EF元数据。
for a given Base
    detect that Name is required and must be <= 32 characters
    act upon that information