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?
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.