/MagicDbModelBuilder

Entity Framework support for building model at runtime

Primary LanguageC#

MagicDbModelBuilder is a set of wrapper classes that enable the creation/configuration of models at runtime
through reflection. A feature that Entity Framework does not support, for now.

What you could do:

var builder = new DbModelBuilder();
builder.Entity<Post>()
  .HasKey(p => p.Id);

... what you couldn't do:

var builder = new DbModelBuilder();
builder.Entity(typeof(Post))
  .HasKey(typeof(Guid), "Id");

... or ...

builder.Entity(typeof(Post))
  .Property(typeof(int), "Id")
  .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

... or ...

builder.Entity(typeof(Post))
  .DateTimeProperty("ModifiedOn", true) // supports nullable with optional parameter 'nullable' set to true 
  .IsRequired();

More implementations to come...