0

Suppose I have the following data model:

public class Base {
    public int Id { get; set; }
    public string Name { get; set; }
}

and the following OnModelCreating():

protected override void OnModelCreating(DbModelBuilder modelBuilder) {
    modelBuilder.Entity<Base>()
        .Property(b => b.Name)
        .IsRequired()
        .HasMaxLength(32);
}

Is detection of the use of Entity Framework's fluent API possible either at compile or run time? In pseudo-code I would like to do something like:

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

For context, I am attempting to generate pseudorandom POCOs that conform to the restrictions placed on it by data annotations or the fluent API. Data annotations are simple enough, but I haven't figure out a way to act on the fluent API use.

jdphenix
  • 15,022
  • 3
  • 41
  • 74
  • Well, you'll have to descend into EF's metadata, but honestly, I have no idea what you're trying to do. – Gert Arnold May 06 '15 at 22:01
  • I want to be able to call some method `Gen()` and get a `Base` object that would successfully save through EF's `SaveChanges()`. I'll look into the EF metadata you mentioned. – jdphenix May 06 '15 at 22:09

0 Answers0