Overblog Tous les blogs Top blogs Entreprises & Marques Tous les blogs Entreprises & Marques
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU
http://kdqfi.over-blog.com/

kdqfi.over-blog.com/

Publicité

Net Framework Mac Visual Studio



I've started playing with Visual Studio 2017 on the Mac, pulling across a sample MVC Core + Entity Framework Core tutorial project on the Microsoft site. The tutorial can be found here.

I run a Windows in a VirtualBox VM on the Mac, so I have a full Windows 10 + VS 2017 Community install with MSSQL 2016 on it.

On the Mac side, I was trying the latest VS 2017 Community for Mac, along with ASP.NET Core.

I was hoping to suss out how much cross-platform compatibility there was, and how much of a poor cousin VSMac was compared to its Windows counterpart, which is still one of my favourite IDEs.

Installing

Visual

Installing VSMac is pretty straightforward and .NET Core is a separate install documented on the Microsoft website.

Extension for Visual Studio - The WiFi Framework is the Software Developer Kit (SDK) for software developers that provides an easy access to the WiFi features on the Windows desktop platforms. WiFi Framework.NET Edition - Visual Studio Marketplace.

Moving the project over to the Mac side

Framework targeting includes the following features: When you open a project that targets an earlier framework version, Visual Studio can automatically upgrade the project or leave the target as-is. When you create a.NET Framework project, you can specify the version of the.NET Framework that you want to target. Visual Studio for Mac.NET. Azure DevOps Server (TFS) 1. Cannot create new ASP.NET Web Application (.NET Framework) windows 6.1 visual studio 2017 version 15.7 project. VinteJ10 reported Jul 11, 2018 at 08:06 AM. Show comments 4. Extension for Visual Studio - The WiFi Framework is the Software Developer Kit (SDK) for software developers that provides an easy access to the WiFi features on the Windows desktop platforms. WiFi Framework.NET Edition - Visual Studio Marketplace. The runtime includes everything you need to run existing apps/programs built with.NET Framework. Download.NET Framework 4.6.2 Runtime. The developer pack is used by software developers to create applications that run on.NET Framework, typically using Visual Studio. Download.NET Framework 4.6.2 Developer Pack.

I started and finished the project on the Windows VM, running on MS Sql Server. This project opens up fine on VSMac. I had some high expectations it would, and it does. It even builds and runs!

Of course, the lack of database access on the Mac side needed to be addressed, but the web project hosted inside VSMac started up and ran just fine in Safari using localhost and a custom port number just as in the Windows VM and Edge.

Converting to use MySQL instead of SQL Server would be the next challenge.

Adding Pomelo for MySQL Support

I didn't find too many options for MySQL. There are some hints on the MySQL blog that MySQL Connector works with Core, but I couldn't actually find a package for the Mac listed in their downloads so I gave up. The one that looked OK is Pomelo.

Pleasantly enough, Pomelo.EntityFrameworkCore.MySql is one of the packages listed when firing up the Project | Add NuGet Packages… option in VSMac.

Simply add the package to your project at this point and you're almost ready to go.

Changing the Entity Framework Provider to MySQL

This was also fairly straightforward. In the Startup.cs file, the database context needs to be adjusted to use MySQL.

From:

To:

The connection string in the appsettings.json was also changed to the MySQL flavour:

Once this was done, running

Visual Studio Net 2003 Download
Net Framework Mac Visual Studio
Bot Framework Visual Studio

dotnet ef update

on the terminal command line in the project directory (where the .csproj file is located) should attach to the configured MySQL instance and create the required tables (in this case, just one) for the sample project.

And voila – things run and the database is created. Quite impressive. You can even add a new movie. But alas, not a second movie…because…

Add Auto Increment to ID field in MySQL

For some reason, the Pomelo provider, or .NET, or something somewhere doesn't know that EF relies on the ID field on the table being an auto incrementing field. This causes any table inserts beyond the first item to fail with a MySqlException: Duplicate entry ‘0' for key ‘PRIMARY'error.

Visual Studio Net Framework 4.7

Wd my passport mac 1tb portable external hard drive. The fix is simple enough; either:

  1. Go into phpMyAdmin and change the row property for the ID column to check the A_I (Auto_Increment) box, then save changes; or
  2. Run a SQL command to do the same thing – something along the lines of

Notes

  1. Entity Framework Core references must be added manually when using VSMac – you can't add this through NuGet right now. The .csproj file must be edited manually to create the references. This appears to be a bug / limitation with just VSMac. Since I started the project on VSWin and moved to VSMac, I didn't have this problem. But I did with a new project started on VSMac. I suspect that moving back and forth between the environments may be quite feasible.
  2. Scaffolding for helping create Insert / Update / Create views does not appear to be present for VSMac while VSWin has an option to create an MVC Controller along with associated views. These would be really handy to help build out your basic CRUD functionality. However, there may be options using Yeoman. More to come.
  3. Razor view tag helpers do not seem to provide syntax highlighting in VSMac.

Next Steps

More research to come, but the next step will be configuring the project so it runs nicely under NGINX or Apache as a Kestrel reverse proxy on the Mac without Visual Studio hosting.





Publicité
Partager cet article
Repost0
Pour être informé des derniers articles, inscrivez vous :
Commenter cet article