Reputation: 1365
I am creating a code-first model. What should my [Table]
attribute be? [Table("PROGRAM_UNIT)"]
or [Table("dbo.PROGRAM_UNIT")]
?
Table property:
Table header in DBML:
Upvotes: 2
Views: 395
Reputation: 20383
If you do not specify the schema name, EF will, by convention, use dbo
.
For Entity Framework 6 and above, the schema can be changed for all tables by using the HasDefaultSchema
method of DbModelBuilder
:
public class CustomContext : DbContext
{
...
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.HasDefaultSchema("MyDefaultDbSchema");
}
}
To change the schema for a specific table you can use the Schema
property of TableAttribute
.
[Table("PROGRAM_UNIT", Schema = "schemaName")]
Upvotes: 2