How to implement the fluent API?

Mar 30, 2011 at 9:03 AM

the EF code first is use the fluent API. 

for example:

public class TestDb : DbContextBase
    {

        public TestDb()
            : base(@"Data Source=.\SQLEXPRESS;Initial Catalog=ORMDb;Integrated Security=True")
        {
        }

        public DbSet<User> Users { get; set; }


        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //Note:mapping to a table ,default table name is users
            modelBuilder.Entity<User>().ToTable("User");

            //Note:set the pk
            modelBuilder.Entity<User>().HasKey(x => x.UserId);


            //Note:
            modelBuilder.Entity<User>().Ignore(x => x.Birthday);
            

        }

    }

.

now how toe implement it ?