maxbeaudoin / MagicDbModelBuilder

Entity Framework support for building model at runtime

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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...

About

Entity Framework support for building model at runtime


Languages

Language:C# 100.0%