Specify an SQL username other than dbo in Code First Entity Framework ( C# ASP.NET MVC 3 )
You can specify the schema using a property on the TableAttribute
that decorates your entity classes.
[Table("TableName", Schema = "mySQLUserName")]
You don't say which version of EF you're using. If you're using Code First (4.1) you can specify the schema on a table attribute:
[Table("Users", Schema = "myschema")]public class User { .. }
You can use Scott's article (the second one) as a basis, but you add an additional parameter. ie.:
modelBuilder.Entity<YourType>().ToTable("TableName", "SchemaName");
With EF6, you can now do this.
protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.HasDefaultSchema("logs"); //set default schema modelBuilder.Configurations.Add(new LogMap()); ... }