EF core using views
To access database view using DbContext, you just need to :
1. POCO - Create your POCO using code shown below. Please note that you need to match exactly the POCO to your views but not necessary all the fields. Let's say you have 10 fields but you can just defined 3 that is of interest to you :
2. Add your DbSet - You need to open up your DBContext and add in your DbSet Manually.
public virtual DbSet
3.OnModelCreating - in your DbContext, add your valuations data as shown below :
The data type used depends on your view.
That should be all the changes you need to make.
Comments