Skip to content

Instantly share code, notes, and snippets.

@trailmax
Created January 15, 2015 16:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save trailmax/fc507480b4f9137225db to your computer and use it in GitHub Desktop.
Save trailmax/fc507480b4f9137225db to your computer and use it in GitHub Desktop.
ApplicationDbContext trying out some overriding stuff
using System.Data.Entity;
using System.Threading.Tasks;
using IoCIdentity.Models;
using Microsoft.AspNet.Identity.EntityFramework;
namespace IoCIdentity.Identity
{
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>, IApplicationDbContext
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public override Task<int> SaveChangesAsync()
{
return base.SaveChangesAsync(); //no problems here
}
}
public interface IApplicationDbContext
{
Task<int> SaveChangesAsync();
//DbSet<Product> Products { get; set; }
}
public class SomeService
{
private readonly IApplicationDbContext dbContext;
public SomeService(IApplicationDbContext dbContext)
{
this.dbContext = dbContext;
}
public async Task SomeAction()
{
var result = await dbContext.SaveChangesAsync();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment