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

Using Breeze in Core web application targeting Full Framework #45

Closed
wijnsema opened this issue Nov 16, 2016 · 6 comments
Closed

Using Breeze in Core web application targeting Full Framework #45

wijnsema opened this issue Nov 16, 2016 · 6 comments

Comments

@wijnsema
Copy link

Dear breeze folks,

The beautiful breeze technology seems to be losing some momentum, but I think it can still add great value in this age of browser oriented application development. A vital step for survival is certainly support for the new .NET Core stack.

Since Entity Framework Core is not yet complete, any serious application needs EF6 anyway. So for starters we might as well use a Core web application targeting the Full Framework.

When I try to add Breeze, a number of things work, some do not. This is what I tried:

Override the default context provider to create the DbContext with a connectionstring (should be placed in setting later on)

public class EfContextProvider : EFContextProvider<MyDbContext>
{
	protected override MyDbContext CreateContext()
	{
		return new MyDbContext("connection string");
	}
}

In Startup.cs

public void ConfigureServices(IServiceCollection services)
{
	// other services ommited

	services.AddScoped<EfContextProvider>(_ => new EfContextProvider());
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
	// other middleware ommitted

	app.UseMvc(routes =>
	{
		routes.MapRoute("BreezeApi", "breeze/{controller}/{action}");
	});
}

In project.json

{
  "dependencies": {
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",

    "EntityFramework": "6.1.3",
    "Breeze.Server.WebApi2": "1.5.5",
    "Breeze.Server.ContextProvider.EF6": "1.5.5"
  },

  "frameworks": {
	"net452": {
		"dependencies": {
			"project containing dbcontext": {
				"target": "project"
			}
		}
	}
  },

//other sections omitted

}

Finally a Breeze controller

[BreezeController]
public class BreezeController : Controller
{
	EfContextProvider contextprovider;
	public BreezeController(EfContextProvider contextprovider)
	{
		this.contextprovider = contextprovider;
	}

	[HttpGet]
	public string Metadata()
	{
		return contextprovider.Metadata();
	}

	[HttpGet]
	[EnableBreezeQuery]
	public IQueryable<Person> Persons()
	{
		return contextprovider.Context.Persons;
	}
}

The metadata is produced OK, and /breeze/persons produces json with Persons.

The problem is that all of the query string parameters like $filter, $top etc seem to be ignored. It seems as something goes wrong with the translation to the Odata layer.

Maybe this just a dead end and I should wait for the final porting, but I have the impression that is can fixed quite easy?

@ganySA
Copy link

ganySA commented Dec 10, 2016

Would love to know if you fixed this?

@wijnsema
Copy link
Author

Sorry, still no solution for this. I went on with a classic full framework API. Would still be nice if dot net Core support was added though...

@senseiweb
Copy link

@steveschmitt @wardbell @jtraband Any recommendation and/or guidance on the path forward?

@jtraband
Copy link
Contributor

looking into this now. The problem is that asp.net core does not yet have OData support. So we are in the process of rewriting the breeze .net server to also support our json query format. This will occur at the same time as a rewrite to support asp.net core. This has the further advantage of decoupling the breeze .net server implementation from OData while still allowing full support for server side EF and full client side queries.

@khuzemakanore
Copy link

Any update on above?

@wijnsema
Copy link
Author

It's working now, please follow this issue: Breeze/breeze.js#178 (comment)

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

5 participants