The easiest way to generate a database schema (people table and others) is to set the database initialization strategy as follows:
Database.SetInitializer<SomeContext>( new DropCreateDatabaseAlways<SomeContext>());
This code needs to be executed before trying to load any data, so the Application_Start () method in Global.asax would be a good place to do this. There are several ways to initialize, so you can take a look at them before choosing one, see http://msdn.microsoft.com/en-us/library/system.data.entity%28v=vs.103%29. aspx and see the methods that implement IDatabaseInitializer. There is officially a default strategy, although I never found that I was working for me.
You should also know that although this method is great for prototyping and development, you cannot use it in a production database with live data, since the database is first deleted and then recreated. There are other ways to do this at this point - see Database Migrations for Entity Framework 4 for features.
As for your other question about using names with an unextended table, there are several ways to do this. One way is to annotate the Person class as follows:
[Table("Person")] class Person {
To set this for all tables at once, you can use the free API, for example:
class SomeContext : DbContext { protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); } }
source share