I am setting up a database using Entity Framework and wanted a bit of clarification regarding creating a DbSet for one of my models.
public DbSet<Customer> CustomersTable { get; set; }
I noticed that the DBset (table) only gets created only if I include the { get; set; } and then add migration. Why is this { get; set; } necessary to be included?
EF Migrations performs an analysis of your codebase prior to creating a migration, which is why your codebase must compile successfully in order to create a migration. This analysis is based upon rules and structures, much like most of the language transformations from source to object code. EF is no different. Syntactically in order to create a migration script that includes new tables, its not the declaration of a class, its the combination of a property with get/setters that makes the table creation work.
No black magic, just rules.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.