I am mapping an existing SQL Server database with Entity Framework 5.0 Code First. The database has a table named, for example 'Device.Widget'. I am trying to map this to an entity named 'Widget'.
If I map it like this ...
[Table("Device.Widget")]
public class Widget
{
//...
}
it works fine. If I map it like this
modelBuilder.Entity<Widget>().ToTable("Device.Widget");
it fails. Viewing the inner exception gives {"Invalid object name 'Device.Widget'."}
More digging reveals that in this case the SQL generated is:
SELECT
...
FROM [Device].[Widget] AS [Extent1]
instead of
SELECT
...
FROM [Device.Widget] AS [Extent1]
If I map it like this ...
[Table("Device.Widget")]
public class Widget
{
//...
}
it works fine. If I map it like this
modelBuilder.Entity<Widget>().ToTable("Device.Widget");
it fails. Viewing the inner exception gives {"Invalid object name 'Device.Widget'."}
More digging reveals that in this case the SQL generated is:
SELECT
...
FROM [Device].[Widget] AS [Extent1]
instead of
SELECT
...
FROM [Device.Widget] AS [Extent1]