Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please help with brief steps to get ASP.Net Core breeze server up #58

Open
bancroftway opened this issue Jul 9, 2017 · 18 comments
Open

Comments

@bancroftway
Copy link

bancroftway commented Jul 9, 2017

It would be extremely helpful to get a list of steps to get an ASP.Net Core Breeze server up, even if a full sample is a bit further away.

BTW, this maybe just me, but sometimes a series of step-by-step instructions are far more instructive than code samples...I found Brian Noyes' Pluralsight video far more helpful than the temphire sample.

@tim-martens
Copy link

tim-martens commented Jul 19, 2017

Hi @bancroftway , I created a sample project here . This includes the basic setup you're looking for.

These are the steps I took to get things working:

  • create a new ASP.NET Core Web Application (.NET Framework - Select the Web API project template)
  • add a Class Library project (.NET Framework) to the solution for the Entity Framework
  • add Entity Framework to both projects in the solution
  • add your context and model classes
  • add a ContextFactory class to the EF project (check this

Then in the web application project:

  • add a reference to the Data project

  • install these nuget packages: see this
    Breeze.Server.Core
    Breeze.Server.Persistence
    Breeze.Server.Persistence.EF6
    Breeze.Server.AspNetCore.NetFramework
    Breeze.Composite.AspNetCore.EF6

  • modify the services configuration in Startup.cs:

public void ConfigureServices(IServiceCollection services)
{
    // Add framework services.
    var mvcBuilder = services.AddMvc();

    mvcBuilder.AddJsonOptions(opt => {
        var ss = JsonSerializationFns.UpdateWithDefaults(opt.SerializerSettings);
        var resolver = ss.ContractResolver;
        if (resolver != null)
        {
            var res = resolver as DefaultContractResolver;
            res.NamingStrategy = null;  // <<!-- this removes the camelcasing
        }

    });

    mvcBuilder.AddMvcOptions(o => { o.Filters.Add(new GlobalExceptionFilter()); });


    services.AddScoped<SchoolContext>(_ => new SchoolContext(Configuration.GetConnectionString("SchoolContext")));
}
  • add a connectionstring the the appsettings.json
  • add a breezeController:
[Route("breeze/[controller]/[action]")]
[BreezeQueryFilter]
public class SchoolModelController : Controller
{
    private SchoolPersistenceManager PersistenceManager;

    // called via DI 
    public SchoolModelController(SchoolContext context)
    {
        PersistenceManager = new SchoolPersistenceManager(context);
    }

    [HttpGet]
    public IActionResult Metadata()
    {
        return Ok(PersistenceManager.Metadata());
    }
    [HttpPost]
    public SaveResult SaveChanges([FromBody] JObject saveBundle)
    {
        return PersistenceManager.SaveChanges(saveBundle);
    }

    [HttpGet]
    public IQueryable<Student> Students()
    {
        return PersistenceManager.Context.Students.Include("Enrollments");
    }
}

internal class SchoolPersistenceManager : EFPersistenceManager<SchoolContext>
{
    public SchoolPersistenceManager(SchoolContext context) : base(context) { }

    // additional stuff goes here. Checkout the NorthwindIBModelController of the Breeze.AspNetCore.InternalTest.sln in the breeze.server.net repo
    // https://github.com/Breeze/breeze.server.net/blob/master/Tests/Test.AspNetCore/Controllers/NorthwindIBModelController.cs
}

Good luck!

@HansHammel
Copy link

Nope! Not working with ASP.NET Core 2.0. Libraries on nuget are build using .net 4.6.1 and therefore incomplatible...

@jasoncowan
Copy link

+1 for ASP.NET Core + EF Core 2.0. Could you pls advise if compatibility with these is on your roadmap?

@jtraband
Copy link
Contributor

We are definitely planning on working on this starting in the next few weeks. Will advise of progress and expected timeframe once we start.

@ahedreville
Copy link

Hi there is any progress on this ?😊

@jtraband
Copy link
Contributor

jtraband commented Jan 2, 2018

I'm a just finishing this up now. Should be putting it up on Nuget within a few days - but the current version ( in test) is already checked into GitHub under breeze.server.net/aspnetcore folder. ( support for both EFCore and EF6 is provided) and an example of sample servers can be found in breeze.server.net/tests/( Test.AspNetCore.EFCore and Test.AspNetCore.EF6).

@mikemichaelis
Copy link

I have all of this working in dotnet core 2.0.....ef core + webapi core + breeze aspnetcore + dotnet-cli + ef-cli

https://github.com/mikemichaelis/dnc

My persistence layer is SQL Server 2017 running in a Linux Docker container. See ya Windows........

@ahedreville
Copy link

ahedreville commented Mar 7, 2018 via email

@plwade
Copy link

plwade commented Nov 22, 2018

Anybody got a Breeze client app working with this .net core backend? https://github.com/mikemichaelis/dnc

I would love to see the client code

@breynolds
Copy link

Is this still open because the breezejs official repo does not yet support dotnet core 2.x? Would be great to have official support. Breeze is a great help for building our applications! @mikemichaelis, we'll still use your dnc repo if we need to.

@jtraband
Copy link
Contributor

Just updated both Asp.net and AspNetCore nugets. For ASP.NET Core with EF Core use the latest versions of Breeze.Core, Breeze.Persistence, Breeze.Persistence.EFCore and Breeze.AspNetCore.NetCore

@gmareater
Copy link

if you know how muuuuuchhhhhhhhhhhhhhhhhh i just waited for this message , hope it works with no bug,
i dont know about others, but i almost forget who to work without breeze, it's one of the must have,
so please do not give up on it

@jtraband
Copy link
Contributor

Thanks, please post back with any issues ... or successes. We have run our full test suite against the new ASP.Net Core and EF Core impl, so the basics should all be there, but edge cases can obviously still occur.

@ganySA
Copy link

ganySA commented Jun 3, 2019

Any chance we could get some docs?

@steveschmitt
Copy link
Member

I finally built a demo project, with steps to create a .NET Core + EF Core server
https://github.com/Breeze/northwind-core-ng-demo
The demo is a .NET Core 2.2 web API, with Angular 8 on the front end.
I hope it helps.

@steveschmitt
Copy link
Member

Note that the demos have been moved to https://github.com/Breeze/northwind-demo

It's a bit out of date because the latest server sample is .NET 5, but the steps to get it going are exactly the same in .NET 6 and 7.

@eqcb
Copy link

eqcb commented Mar 11, 2024

Note that the demos have been moved to https://github.com/Breeze/northwind-demo

It's a bit out of date because the latest server sample is .NET 5, but the steps to get it going are exactly the same in .NET 6 and 7.

Hello Steve,

The steps in the .NET 5 server sample call for Startup.cs class configuration. The current templates for ASP.NET use only the program.cs. Can you guys update the sample or point to some updated example?

And for an ASP.NET API, do we still need to call services.AddMvc(); ?

Thanks!

@steveschmitt
Copy link
Member

@eqcb You are right - things have changed enough that we need to update the samples. We'll work on putting a .NET 8 sample up soon.

For an ASP.NET API, I think you should use services.AddControllers().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests