0

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 ?

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.