没有主键的表的Scaffold-DbContext创建模型
问题描述:
我正在尝试为ASP.NET核心MVC应用程序中的特定表创建DBcontext和相应的模型.该表没有任何主键.
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.
我正在运行Scaffold-DbContext命令-
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
在Package Manager控制台中,我可以看到此详细输出-
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'.
我的环境是-VS2015 update3,.NET core 1.0.0,ASP.NET MVC核心应用程序.
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?