Please enable JavaScript.
Coggle requires JavaScript to display documents.
EF Core - Coggle Diagram
EF Core
When not use
if the ef core not supported by EF core
Although core is faster but not faster than pure sql due to level of abstraction
not very good with Bulk operation alternatively use
dapper
Code First
Configuration
Microsoft.EntityFrameworkCore.SqlServer
Microsoft.EntityFrameworkCore.Tools
Create a new C# class named
ApplicationDbContext
and Inherits from
DbContext
Configure Connection string by override
OnConfiguring
method using
optionsBuilder.UseSqlServer
builder.services.AddDbContext<ApplicationDbContext>(options=>options.UseSqlServer(connectionStrings))
Create a Entity class called Person
Configure it in ApplicationDbContext class using DbSet<Person> Persons {get;set:}
Then run migrations command
add-migration initialDb
then
update-database
Create a parameterless constructor and pass the option to inherited constructer
Modelling Database
when to use
when you have to do a lot of CRUD
if you need to support multiple DB engine
Its an ORM (object relational mapper) library
DB First