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

Edited Issue: Bug mapping a table named with a dot character [543]

$
0
0
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]




Viewing all articles
Browse latest Browse all 10318

Trending Articles