I'm in OSX and I'm creating a new ASP.NET Core Web API. I've followed this tutorial: https://docs.efproject.net/en/latest/platforms/netcore/new-db-sqlite.html
That's cool and all but what about Sql Server? Now I know SQL Server won't yet run on OSX (https://www.microsoft.com/en-us/cloud-platform/sql-server-on-linux).
The only way I can see to make this work is if I create a cloud remote SQL server (on Azure or similar), then connect with it from my ASP.NET core application. I tried following this, but it assumes VS2015 https://docs.efproject.net/en/latest/platforms/aspnetcore/existing-db.html. We don't have the package manager console in VSCode and I don't know if there is an equivalent to Scaffold-DbContext.
So how do I make a connection to SQLServer and how do I do things like EF migrations to update that database.
All the packages download can be done without the package installer, by using project.json and dotnet restore (if VSCode doesn't do it when project.json is saved).
With the tools installed, you can create migrations with dotnet ef migrations add <migration name> and dotnet ef database update to apply the migrations to the db schema.
Class libraries (where DbContext and models are defined in class library) are not supported yet. There is a workaround in the Entity Framework Core docs though.
For scaffolding the usage is dotnet ef dbcontext scaffold [arguments] [options]. See the Scaffolding docs for details.
Related
Evening.
I have to develop an api for an existing SQL Server 2017 database.
I need to use Microsoft Web API, and I would like to use Core 3.1 but I have read I have to use migrations and such, and i have been told not to build the api using migrations.
Would I be better using .Net Framework instead or is there a way to use Core without using migrations?
I hope that it's not too broad a question, but I really am struggling to make a decision so any feedback etc would be greatly appreciated.
carlson
If you'd like to access data from an existing database and tables with Entity Framework (EF) Core in your ASP.NET Core Web API project, you can try to use Scaffold-DbContext command or dotnet ef dbcontext scaffold command to generate code for a DbContext and entity types for your database.
Besides, you can also install and use Microsoft.Data.SqlClient to access your existing SQL Server database in ASP.NET Core project.
I have a DB project which relies on SQL Server Database tools. I am trying to work on it on a Mac. The rest of the project is in .NET Core so that all works well. The database project throws an error on dotnet restore
/Users/mborozdin/src/ethos/FileRepository/src/FileRepository.Database/FileRepository.Database.sqlproj(63,3): error MSB4019: The imported project "/usr/local/share/dotnet/sdk/2.1.4/Microsoft/VisualStudio/v10.0/SSDT/Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
Is there an alternative to SSDT which seems to be only available on Windows?
When you develop on the Mac,
You will put your SQL Server on the docker or Virtual Machine.
In other to connect, You need SQL Operations Studio for the Mac
Download Link
Is there an alternative to SSDT which seems to be only available on Windows?
The alternative is Azure Data Studio. As for:
SQL Database Projects extension
The SQL Database Projects extension brings project-based database development, well-known in SQL Server Data Tools (SSDT), to the cross-platform Azure Data Studio experience. From this early insiders release you can create, build, and publish a project from scratch or an existing database.
https://github.com/microsoft/azuredatastudio/issues/11105
starting using VS2015 and publishing to azure websites. I'm developing using a local DB for faster interaction. And I'm publishing Web Application and a SQL Database (Project > publish). But I always getting this error.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(4276,5): Error ERROR_SQL_EXECUTION_FAILURE:
"CREATE TABLE [dbo].[__MigrationHistory](" There is already an object named '__MigrationHistory' in the database" #ERROR_SQL_EXECUTION_FAILURE.)
Publish failed to deploy.
And it is the same for every table on DB.
How can I somehow just update the tables on the server?
There is another way to work with apps and DB in local machine and later update to the server?
I'm using vs2015, webDeploy 3.6, Windows Azure web app and SQL DB.
I got this solved by removing all files from Properties\PublishProfiles. There was lots of old files from my first publishing attempts. After this I created new profile.
I have just finished an standalone desktop application in C# and .Net. For the app, I need to access several existing SQL Server tables for various data. I accomplished it with Entity Framework 6 code first. My question is how I should update the connection string in app.config during a customer installation to reflect customer's SQL Server configurations. What steps are generally involved? What options are available to me? I'll use Inno Setup for the app installation.
Thank you.
I am looking for a means to use Git deployment on Windows Azure together with either their MySQL or other database solutions.
I need a means of migrating database schema changes as part of deployment - does Azure provide support for this without using Visual Studio or .NET.
You basically want to use Azure as a Continuous Integration (CI) platform and my view is that Azure by itself just isn't there yet.
A basic git based CI scenario would involve the following steps.
Your src code and any database schema/data updates are pushed to a central git repository like GitHub. [Feature available]
GitHub would then push the updates to Azure. [Not supported in Azure until they support GitHub hooks]
Azure compiles and deploys the code. [Supported]
Azure updates the database from sql files pulled from the repo (remember, this needs to be automated). [Not supported]
Azure reports any error in running the database or web application. [Supported]
Azure runs user provided integration tests to check more thoroughly specific functionality and reports the status of those tests to the user [Not supported].
Azure allows you to roll back to a previous deployment snapshot [Partly supported. Snapshots are not based on git commits for instance].
I might be wrong on some of those points or new features might be added since I've written this. Corrections are very welcomed and I'll try to update the list accordingly.
I am not sure how much experiences you have with Windows Azure Websites, however when you are creating a Windows Azure Websites, you have ability to use SQL Azure Database or MySQL cloud database directly integrated with your Windows Azure Websites.
So if you will use SQL Azure Database then there are several ways you can migrate your DB following the link here:
Migrating Databases to Windows Azure SQL Database (formerly SQL Azure)
To manage MySQL you can use Local Web Server to do it. The way I have done is to use PHP, the MySQL Command-Line Tool (part of MySQL), and a web server set up on my local machine, and that I have enabled the PDO extension for MySQL. This way I can manager my MySQL directly from my own local machine and the details are explain at the bottom of this article:
Create a PHP-MySQL Windows Azure web site and deploy using Git.
Also the SQL part you can write in Workbench if you use MySQL and Oracle SQL Developer if you use Oracle SQL.
Finally Git Deployment allows you to deploy your any kind of application directly to Windows Azure without using VSx.