ça fait 1 moment que j'avais quitté lemonway, j'ai appris bcp des choses, voici quelque découvert qui peut être useful pour vous mes amis!
The .dacpac file is your database's "blueprints." It includes:
- Tables and Indexes: Columns, data types, primary/foreign keys.
- Programmability: Stored procedures, scalar-valued and table-valued functions.
- Views: The logic and definitions of all views.
- Constraints: Check constraints, default values.
- User-defined types: Custom data types you've created.
Create a .sqlproj project, put all your *.sql inside.
Build it dotnet build it should generate .dacpac file in bin/debug.
-
🙏 The .dacpac is portable, and can be versioned in git
-
🙏 Database migration
Example: When you want to add a new column to the database
-
Today: You manually write
ALTER Table ADD column.... You have to combine theCREATE tablewith all theALTER tablein order to know what your final table look likes. -
With
.dacpac: Just add the new column in the existingCREATE tablescript. The CI/CD is able to compare 2 .dacpac files (v1.dacpac vs v2.dacpac) and generate SQL migration script automatically.
It would know that there is a new column in v2.dacpacand generate the ALTER table ADD column..
- 🙏 Entity framework scaffolding without SQL Server
-
Today: Amine is developing a new feature which require a new column / table. In order to scaffold the EF DbContext, he will have to "deploy" the new column to a SQL Server (usually a Dev database or his LocalDB).
-
With
.dacpac: Amine can simply add the column to .sql file, generate the .dacpac and scaffold the EF DBContext from the .dacpac directly:
dotnet ef dbcontext scaffold mydatabase.dacpac ErikEJ.EntityFrameworkCore.SqlServer.Dacpac -c MyDbContext
Note: I know that you also need some data in the database. A .dacpac which contains data is called .bacpac (Backup Archive).
Reference: https://github.com/VerifyTests/Verify
Today: Look at all the Assert of Gab in your C# tests 🤮 !
- Our test do a lot of Assert - there is so much Assert that we split them into shared functions. These functions reduce the number of repeating Assert codes we have to write, but it also increase the difficulty in maintenance when there are shared Assert codes across tests.
- Even though, many meaning-full "Assert" are still missing (until we add them)
With verify: We can have a lot lot more Assert with barely minimum of codes. Look at this example:, I wrote one line of code
await Verifier.Verify(logsSnapshot, _vsettings);
which Assert a whole big chunk of information x Complex Objects in depth. This one line of codes should be able to Assert not only the final result but also the intermediary steps.