GithubHelp home page GithubHelp logo

s02e01-rest-api-.net-core's Introduction

S02E01-REST-API-.Net-Core

Example of a full REST API build using .Net Core 2.2 and c#

s02e01-rest-api-.net-core's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

s02e01-rest-api-.net-core's Issues

.NET CORE SDK 3.0.100 - EF Migration Failed

When developing this project using .NET Core SDK (3.0.100-preview6-012264), I am getting below migration error upon running this command "dotnet ef migrations add AddCommandsToDB -v"

Issues:

Using project 'E:\C#API\CommandAPI\CommandAPI.csproj'.
Using startup project 'E:\C#API\CommandAPI\CommandAPI.csproj'.
Writing 'E:\C#API\CommandAPI\obj\CommandAPI.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\vinot\AppData\Local\Temp\tmpFD55.tmp /verbosity:quiet /nologo E:\C#API\CommandAPI\CommandAPI.csproj
Writing 'E:\C#API\CommandAPI\obj\CommandAPI.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\vinot\AppData\Local\Temp\tmp2A5.tmp /verbosity:quiet /nologo E:\C#API\CommandAPI\CommandAPI.csproj
dotnet build E:\C#API\CommandAPI\CommandAPI.csproj /verbosity:quiet /nologo

Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:03.28
dotnet exec --depsfile E:\C#API\CommandAPI\bin\Debug\netcoreapp3.0\CommandAPI.deps.json --additionalprobingpath C:\Users\vinot.nuget\packages --additionalprobingpath "C:\Program Files\dotnet\sdk\NuGetFallbackFolder" --runtimeconfig E:\C#API\CommandAPI\bin\Debug\netcoreapp3.0\CommandAPI.runtimeconfig.json C:\Users\vinot.nuget\packages\dotnet-ef\3.0.0-preview6.19304.10\tools\netcoreapp3.0\any\tools\netcoreapp2.0\any\ef.dll migrations add AddCommandsToDB --assembly E:\C#API\CommandAPI\bin\Debug\netcoreapp3.0\CommandAPI.dll --startup-assembly E:\C#API\CommandAPI\bin\Debug\netcoreapp3.0\CommandAPI.dll --project-dir E:\C#API\CommandAPI\ --language C# --working-dir E:\C#API\CommandAPI --verbose --root-namespace CommandAPI
Using assembly 'CommandAPI'.
Using startup assembly 'CommandAPI'.
Using application base 'E:\C#API\CommandAPI\bin\Debug\netcoreapp3.0'.
Using working directory 'E:\C#API\CommandAPI'.
Using root namespace 'CommandAPI'.
Using project directory 'E:\C#API\CommandAPI'.
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding application service provider...
Finding IWebHost accessor...
No CreateWebHostBuilder(string[]) method was found on type 'CommandAPI.Program'.
No application service provider was found.
Finding DbContext classes in the project...
Found DbContext 'CommandContext'.
Microsoft.EntityFrameworkCore.Design.OperationException: Unable to create an object of type 'CommandContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728 ---> System.MissingMethodException: No parameterless constructor defined for type 'CommandAPI.Models.CommandContext'.
at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type)
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.<>c__DisplayClass12_3.b__13()
--- End of inner exception stack trace ---
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.<>c__DisplayClass12_3.b__13()
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func1 factory) at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType) at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_1.<.ctor>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_01.b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Unable to create an object of type 'CommandContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

Programs.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace CommandAPI
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>();
            });
}

}

Note: I am trying to use MySQL DB:

"Data":
{
"CommandAPIConnection":
{
"ConnectionString" : "Server=localhost;port=3306;user=root;Database=CommandAPI;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}

.csproj

netcoreapp3.0 ---------------------------------------------

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.