ASP.NET MVC project using Entityframework

Asked

Viewed 28 times

0

Guys, a very beginner question, I did an ASP.NET MVC project using the Entityframework, I did using the standard Unitofwork:

public class UnitOfWorks : IDisposable
{

    // Context
    private AgendaContext _context = new AgendaContext();

    //propfull tab tab 
    private IClienteRepository _clienteRepository;

    public IClienteRepository ClienteRepository
    {

        get
        {
            if(this._clienteRepository == null)
            {
                this._clienteRepository = new ClienteRepository(_context);
            }
            return _clienteRepository;
        }

    }

    //SaveChanges
    public void Save()
    {
        _context.SaveChanges();
    }

    private bool _disposed = false;

    public void Dispose(bool disposing)
    {
        if (!this._disposed)
        {
            if (disposing)
            {
                _context.Dispose();
            }
        }
        this._disposed = true;
    }

    //Fechar a conexão... liberar o recurso
    public void Dispose()
    {
        Dispose(true); //Libera a conexão do context
        GC.SuppressFinalize(this); //Finaliza o UnitOfWork
    }
}

}

I want to know if I can use the Mysql or Oracle database in this project with Entity Framework. And how do I set up the database, from the first step, I create a database within the same project? What are the codes.

  • 1

    Yes, it is possible, but your question is completely outside the scope of the site.

  • Entity Framework already implements Unit of Work. You do not need to do this again: http://answall.com/questions/51536/quando-usar-entity-framework-com-repository-pattern/80696#80696

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.