visual studio mac for mac missing of identity clas

2019-02-05 11:11发布

问题:

Hi i downloaded visual studio for mac 2017 community version. I created a default MVC Core 2.0 project and i noticed that there is missing class of Account controllers where it used to have register and account other handler functions.

i created the same project in windows .In windows i can see that there is identity class and controller created.

how do i generate this authentication class in visual studio for mac Core 2.0?

I tried creating the default project in windows and copy to mac and it works!!! After i change the connection string to the server.Identity framework works fine in mac. But why is microsoft not generating the code for mac?

回答1:

ok this is the command to include authentication for mac ok visual studio 2017 core 2.0.

 dotnet new mvc -o moviemvc --auth Individual

once u register a new account. it will create a new database in the folder with app.db which is filebase database i believe. open db use this sql lite browser to open it and view the content of it.

if you want to use sql server instead then you will need to add this into the line when create new project with terminal. add it in front of --auth will do

-uld


回答2:

With Visual Studio on Windows there are extra options you can configure when creating a new ASP.NET Core project. These extra configuration options are not currently available with Visual Studio for Mac so a simpler ASP.NET Core project is created.

So you are left with copying the project from Windows, as you already did, or you can open a command prompt and use dotnet new to create a project. If you run the following you can see what configuration options you can specify for the ASP.NET Core MVC project template:

 dotnet new mvc --help


回答3:

Currently the GUI for Mac Visual Studio does not support the ability to add Authentication. However, the CLI does!

  1. dotnet new sln --name <filename>

    • This will create a new sln
    • If you don't use the --name flag the sln will take the current folder's name
  2. dotnet new mvc -o moviemvc --auth Individual

    • This will create a new .csproj with mvc and Authentication (Identity models) included
  3. dotnet sln add </filepath>

    • This will add the file to the sln in the folder (if exists)
  4. dotnet sln <path-to-solution.sln> add <path-to-project.csproj>

    • If you have multiple sln's in the folder, you will have to specify the sln you want to target

You can find more information here too