如何使用实体框架部署或共享代码优先项目

发布于 2025-01-18 03:21:03 字数 354 浏览 0 评论 0原文

我使用.NET 6和EF制作了一个小的REST API,数据库位于Microsoft SQL Server中。我生成了我的课程和控制器,但是现在我想将其发送到同伴,我想让同伴在自己的计算机上运行它尽可能容易。这些是当时的迁移:

  1. ​需要在他们的计算机中安装我的项目吗?
  2. 我需要做什么才能生成.exe在其他机器中运行该项目?
  3. 是否有免费的方法将其部署到Azure或其他云环境中?

谢谢。

I made a small REST API with .NET 6 and EF, the database is in Microsoft SQL Server. I generated my classes and my controllers but now I want to send it to a peer and I want to make it as easier as possible for the peer to run it in its own computer. These are the migrations at the time:

migrations

My concern is that I generated my database with an already running SQL Server agent and such, then I used EF to update the database so this raises a few questions:

  1. What does my peer need to install in their computer to run my project?
  2. What do I need to do to generate .exe's to run the project in some other machine?
  3. Is there a free way to deploy this into Azure or some other cloud environment?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

兲鉂ぱ嘚淚 2025-01-25 03:21:03

我的同伴需要在计算机上安装什么才能运行我的项目?

您的同行可以在收到发布文件和 sql脚本之后运行。这样,他只需要Web服务器(IIS)和SQL Server(Express等)。对于开发的目的,他必须提供与.NET框架的相同版本和类似于或能够转换解决方案的编译器。对于数据库,他可以在MSSQLServer的不同版本/分发上执行SQL脚本(除非您采用特定于发行版的高级功能)。

我需要做什么才能生成.exe在某些中运行该项目
其他机器?

只需发布您的项目。这足以在具有相同版本的.NET框架的Windows机器上运行。您也可以使用 bin 目录中的生成文件(不推荐)。

是否有一种免费的方法将其部署到Azure或其他云中
环境?

大多数云服务免费提供有限的服务。这取决于您的申请要求。

What does my peer need to install in their computer to run my project?

Your peer can run it just after receiving the published files and SQL script. In this way, he only needs a web server (IIS) and SQL Server (Express, etc). For the development purpose, he has to provide the same version of the .net framework and a compiler similar to or capable of converting your solution. For the database, he can execute the SQL scripts on a different version/distribution of MSSQLSERVER (unless you employ advanced features that are distribution-specific).

What do I need to do to generate .exe's to run the project in some
other machine?

Just publish your project. This is enough to run on windows machines having the same version of .net framework. You can use the generated files inside the bin directory too (not recommanded).

Is there a free way to deploy this into Azure or some other cloud
environment?

Most of the cloud services offer limited services at no cost. It depends on your application requirements.

无远思近则忧 2025-01-25 03:21:03

1-您的朋友需要在他的计算机上安装具有正确版本的 .net 的 Visual Studio,以及正在运行的 SQL Server 实例(本地或远程)。

2-如果您希望您的项目在其他人的计算机上运行,​​而无需运行 SQL Server 实例,您可以使用 EF 的 InMemoryDatabase (有一些限制,但适用于小型项目)。我不是专家,但我认为你也可以为你的 api + 数据库使用 docker 镜像。

3- 有很多云提供商提供免费或廉价的托管计划。 Azure 对某些学生来说是免费的,但其他情况下是付费服务。

1- Your friend needs to have visual studio with the correct version of .net on his computer, and a running SQL Server instance (local or remote).

2- If you want your project to run on someone else's machine without the hassle of running an SQL Server instance, you could use EF's InMemoryDatabase (there are some limitations but works on small projects). I'm not an expert but I thing you could also use a docker image for your api + database.

3- There are plenty of cloud providers that offer free or cheap hosting plans. Azure can be free for some students, but is a paid service otherwise.

旧瑾黎汐 2025-01-25 03:21:03

您可以创建新的Azure帐户,并使用免费的启动奖金(例如50美元)在数据库中部署您的应用程序。出于相同的原因,我在Azure应用程序中部署了Azure,并且我一起为应用程序和数据库支付了5美元(因为我已经使用了奖金)。
只需要仔细制定您的订阅计划即可。因此,每个人都可以从任何地方打开并操作您的应用程序。

您可以直接连接到Visual Studio与Azure发布。

您可以在YouTube中使用许多指南的一些直接部署
https://www.youtube.com/watch?v=mog4yp7zmrc

You can make new Azure account and use the free starting bonus(like 50$) to deploy your app with your database on. I deploy in Azure my apps for the same reason and I pay 5$ a mount(because I used already the bonus) for the app and database together.
Just need to make your subscription plan carefully. So everyone can open and operate your application from everywhere.

You have direct connection for publishing to Azure from Visual Studio.

You can use some from many guides in YouTube for the direct deployment
https://www.youtube.com/watch?v=MOG4yp7Zmrc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文