在Code-First迁移脚本中运行SQL查询的替代方法是什么?
目标是将数据添加到DB表中。 我可以生成一个空的迁移脚本,然后将其添加到UP()方法中。
migrationBuilder.Sql($"INSERT INTO [User].[ExtraUser](Id,Name,Description)" +
"Values('123','Extra1', 'description')"
这起作用了,但是在某些情况下,我必须在许多列中添加数据,并且编写插入脚本似乎很不舒服。有更好的选择吗?
Goal is to add data to DB table.
I can generate an empty migrations script and add this in Up() method.
migrationBuilder.Sql(quot;INSERT INTO [User].[ExtraUser](Id,Name,Description)" +
"Values('123','Extra1', 'description')"
This works but there are cases where I have to add data in lots of columns and writing insert script seems rather uncomfortable. Is there a better alternative to this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论