https://github.com/megabytemark/intradotnet-entityframeworkcore-infrastructure
Optimization classes to remove boilerplate when generating entityframework dbcontexts
https://github.com/megabytemark/intradotnet-entityframeworkcore-infrastructure
Last synced: about 1 year ago
JSON representation
Optimization classes to remove boilerplate when generating entityframework dbcontexts
- Host: GitHub
- URL: https://github.com/megabytemark/intradotnet-entityframeworkcore-infrastructure
- Owner: MegaByteMark
- License: mit
- Created: 2024-12-24T20:00:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-23T21:55:05.000Z (over 1 year ago)
- Last Synced: 2025-06-01T12:59:23.514Z (about 1 year ago)
- Language: C#
- Size: 59.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# IntraDotNet EntityFrameworkCore Infrastructure
Optimization classes to remove boilerplate when generating EntityFramework DbContexts, their associated entities and implementing common functionality like row based change auditing, soft deleting and optimistic concurrency, repository and unit of work patterns.
## Getting Started
### Prerequisites
- .NET 9.0 SDK or later
- EntityFrameworkCore 9.0 or later
### Installation
1. Add the NuGet package to your project:
```sh
dotnet add package IntraDotNet.EntityFrameworkCore.Infrastructure
```
### Usage
1. Create your DbContext class inheriting from `DbContext`:
```csharp
public class MyDbContext : DbContext
{
public DbSet MyEntities { get; set; }
}
```
2. Create your repository class inheriting from `BaseAuditableRepository`:
```csharp
public class MyEntityRepository : BaseAuditableRepository
{
public MyEntityRepository(IDbContextFactory contextFactory) : base(contextFactory)
{
}
}
```
3. Use the repository in your application:
```csharp
var repository = new MyEntityRepository(contextFactory);
var entities = await repository.GetAllAsync();
```
## Contributing
Contributions are welcome! Please submit a pull request on GitHub.
1. Fork the repository.
2. Create a new branch (`git checkout -b feature-branch`).
3. Make your changes.
4. Commit your changes (`git commit -am 'Add new feature'`).
5. Push to the branch (`git push origin feature-branch`).
6. Create a new Pull Request.
## License
This project is licensed under the MIT License. See the [LICENSE](http://_vscodecontentref_/1) file for details.