You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In past pre-release of EF Core, the table name for an entity was the same as the entity class name. In RC2 we now use the name of the DbSet property. If no DbSet property is defined for the given entity type, then the entity class name is used.
For example, given the following model, in RC1 the table name for Blog would have been dbo.Blog, in RC2 it will be dbo.Blogs.
If you upgrade an app from RC1 to RC2, you have several options:
If you are generating the database from the model, you can scaffold a new migration to apply the naming changes (or drop and recreate the database if you are using EnsureCreated() rather than migrations).
Manually specify table names to match what was chosen in RC1. This can be done in OnModelCreating or with the [Table] attribute. See the docs for more info.
Use the code from the following section to bulk configure table names to match what was chosen in RC1.
Reverting to RC1 naming
If you want to revert back to the RC1 naming conventions for tables, add the following code to the start of the OnModelCreating method on your context (requires a using statement for Microsoft.EntityFrameworkCore.Metadata.Internal).
In past pre-release of EF Core, the table name for an entity was the same as the entity class name. In RC2 we now use the name of the DbSet property. If no DbSet property is defined for the given entity type, then the entity class name is used.
For example, given the following model, in RC1 the table name for
Blog
would have beendbo.Blog
, in RC2 it will bedbo.Blogs
.Impact on existing apps
If you upgrade an app from RC1 to RC2, you have several options:
EnsureCreated()
rather than migrations).OnModelCreating
or with the[Table]
attribute. See the docs for more info.Reverting to RC1 naming
If you want to revert back to the RC1 naming conventions for tables, add the following code to the start of the OnModelCreating method on your context (requires a
using
statement forMicrosoft.EntityFrameworkCore.Metadata.Internal
).The text was updated successfully, but these errors were encountered: