reading-notes

Entity Framework Core

Entity Framework Core (EF Core) is a lightweight and cross-platform version of the Entity Framework data access technology. It serves as an object-relational mapper (O/RM), allowing .NET developers to work with databases using .NET objects and reducing the need for manual data-access code. EF Core supports various database engines and provides flexibility in model development approaches.

With EF Core, data access is performed through a model consisting of entity classes and a context object that represents a session with the database. LINQ is used for querying data, and changes to the database are made by manipulating instances of entity classes. Best practices such as understanding the underlying database server, testing, performance optimization, security review, logging, error recovery, and migration planning should be considered when using EF Core in production applications.

Entity Framework Core provides multiple ways to seed data into a database:

Enabling User Secrets involves adding a secrets.json file to your project, which contains key/value pairs of your secret information. This file is not uploaded to source control but is stored securely on your local machine.

To access User Secrets within your code, you need to configure the project to use the secrets.json file. This is done by modifying your .csproj file and adding the UserSecretsId and DotNetCliToolReference.

In your controllers or other parts of your code, you can access the secrets using the Configuration API provided by .NET Core. Inject the IConfiguration object into your controller’s constructor and use Configuration[“KEY”] to retrieve the secret values.

When deploying to Azure, you can add the user secret data as environment variables in the application settings of your Azure App Service, ensuring that the secrets are securely stored in the production environment.

Things I want to know more about it

Dive deeper into API Designing . Home