如何在.NET Core 1.0中使用Entity Framework运行SQL脚本?

编程入门 行业动态 更新时间:2024-10-20 08:25:30
本文介绍了如何在.NET Core 1.0中使用Entity Framework运行SQL脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在ASP.NET MVC Core 1.0项目中运行sql脚本。答案在这里:我们可以使用代码优先迁移来运行sql脚本吗? 几乎完全解释了我想要做什么,除了以下内容:

I'd like to run sql scripts in an ASP.NET MVC Core 1.0 project. The answer here: Can we run sql script using code first migrations? pretty much explains exactly what I want to do, except that for this line:

Sql(File.ReadAllText(sqlFile));

它吠叫说名称'Sql'在当前上下文中不存在 。 我确定.NET Core 1.0中一定有一种方法。 我刚刚开始使用.NET Core 1.0,因此可能缺少一些简单的东西。

it barks and says "The name 'Sql' does not exist in the current context". I'm sure there must be a way in .NET Core 1.0. I'm just getting started with .NET Core 1.0, so it may be something simple that I'm missing.

推荐答案

private class SomeMigration : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.Sql(File.ReadAllText(sqlFile)); } protected override void Down(MigrationBuilder migrationBuilder) { } }

更多推荐

如何在.NET Core 1.0中使用Entity Framework运行SQL脚本?

本文发布于:2023-11-14 19:42:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1588344.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   如何在   Core   NET   Framework

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!