Anduin Xue

let today = new Beginning();

Entity Framework and SQL Server Topics about Entity Framework and SQL Server


EF second layer cache to enhance your SQL database performance based on Redis

Entity-Framework Core is a lightweight, extensible, open-source, and cross-platform version of the popular Entity Framework data access technology. It really helps the developer to build applications which access database easily. But in most cases, we may cache some results which do not change frequently, to reduce access to our database. For example, the home page of a blog may not change  …

ASP.NET Core C# SQL Server SQL Entity Framework Core Azure Redis Caching Cache

Creating a Model for an existing database in Entity Framework Core (DB First)

Install EF first: dotnet tool install --global dotnet-ef Try to execute the following command under your project folder: $ dotnet ef dbcontext scaffold "Server=....." Microsoft.EntityFrameworkCore.SqlServer -o Models And fill the string Server=..... with your database connection string. Make sure that you can connect to this database successfully. And EF will try to build models from the  …

C# Entity Framework SQL Server Database Entity Framework Core LINQ

Sync data to database with Entity-Framework Core

We already know how to add data to database. That's simple: _dbContext.MyDbSet.Add(myObject); But there may already exists some data in the database. We need to delete the obsolete data, and try to add the missing data. For example, I have some numbers: 1, 1, 2, 2, 3, 3 While in the database there is: 1, 1, 1, 5 To seed the database to the way we expected, we shall delete the first 1 and  …

C# Entity Framework Database Data Sync


Soft deletion in Entity Framework Core

Soft deletion feature is important in some cases that you need a second step to delete the data in your database. When you first delete it from your C# LinQ query, the data will only be marked as Deleted but not delete in your database. Multi-tenancy is one of the ASP.NET boilerplate's important features. But how can we implement the soft-deletion feature with only pure Entity Framework Core?  …

C# Entity Framework SQL Server Soft deletion

Support multi-tenant in pure Entity Framework Core

Multi-tenant requires many features because the data can be separated by different tenants. So when you are accessing the database, you don't need to worry that your operation will affect other tenants. Multi-tenancy is the ASP.NET boilerplate's most important feature and works perfectly with Domain-driven design. But how can we implement the multitenant feature with only pure Entity Framework  …

ASP.NET Core C# Entity Framework Multi-tenant

Auto update database for ASP.NET Core with Entity Framework

If your ASP.NET Core project is connecting to your database via entity framework, you can't be unfamiliar with the script: dotnet ef database update. Without executing the script your database is not the latest and this may cause some issues. Traditionally we update the database every time we start our app or publish our app. But we may forget this process and it costs us work. How can we  …

ASP.NET Core C# Entity Framework SQL Server

How to fix SQL Server database suspect status

In case our SQL Server database can't access, and telling you that it was in suspect status: Common reasons for the state are: The system cannot open the device where the data or log file is located The specified file was not found during the creation or opening of the physical device SQL Server crashes in the middle of the transaction Unable to access data or log files when going online  …

SQL Server SSMS SQL

  • 1