Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Commented Issue: Some of the ToTable methods ignore schema included in name [894]

$
0
0
Mapping an entity to a table with a name in the format "schema.table" does not always work as expected. The following will map Blog to the schema name:
```
modelBuilder.Entity<Blog>().ToTable("Schema.TableName");
```
But the following will not, EF will attempt to add dbo to the start of the name:
```
modelBuilder.Entity(typeof(Blog)).ToTable("Schema.TableName");
```
The ToTable methods inside a many-to-many mapping configuration also do not parse the schema.


The workaround for this is to use the overload of ToTable that accepts schema name:
```
modelBuilder.Entity(typeof(blog)).ToTable("TableName", "Schema");
```
Comments: This may be related to [Work Item 716](http://entityframework.codeplex.com/workitem/716).

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>