David Merinos
David Merinos

Reputation: 1295

How to deploy or share code-first project with Entity Framework

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.

Upvotes: 1

Views: 381

Answers (3)

Amirhossein Mehrvarzi
Amirhossein Mehrvarzi

Reputation: 18954

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.

Upvotes: 1

Darkk L
Darkk L

Reputation: 1035

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

Upvotes: 0

madmax
madmax

Reputation: 74

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.

Upvotes: 0

Related Questions