Scaffold-DbContext creating model for table without a primary key

asp.net-core asp.net-core-mvc entity-framework entity-framework-core

Question

I am trying to create DBcontext and corresponding model for a particular table in ASP.NET core MVC application. This table doesn't have any primary key.

I am running following Scaffold-DbContext command-

Scaffold-DbContext "Server=XXXXX;Database=XXXXXXX;User Id=XXXXXXX;password=XXXXXXX" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -t TABLE_NAME -force -verbose

In Package Manager Console, I can see this verbose output-

...............
...............
Unable to identify the primary key for table 'dbo.TABLE_NAME'.
Unable to generate entity type for table 'dbo.TABLE_NAME'.

My Environment is - VS2015 update3, .NET core 1.0.0, ASP.NET MVC core application.

Is there anyway to create a model for a table without primary key?

1
19
9/26/2016 10:59:13 AM

Accepted Answer

Support for complex types (those that don't have an entity key) in EF Core is on the backlog: https://github.com/aspnet/EntityFramework/issues/246. That's why any attempt to reverse engineer a table without a primary key defined won't work at the moment.

16
9/26/2016 11:25:32 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow