EF Core 3.0 Stored procedures custom view model

.net-core asp.net-core-3.0 ef-core-3.0 entity-framework-core

Question

i upgraded from .net Core 2.1 to 3.0, but i cant get my stored procedures working, so here is what i have.

i am having a few sp which return data from many different tables, so i created a class with all the custom fields that will be returned, and inside the context class i map them.

in 2.1 i did it like this.

public DbQuery<ProductByKeyword> ProductBriefInfoModel { get; set; }


builder.Query<ProductByKeyword>();

and in 3.0 i changed it to.

public DbSet<ProductByKeyword> ProductBriefInfoModel { get; set; }

builder.Entity<ProductByKeyword>().HasNoKey();

now this is not working with an error that i need to add migration, and upon adding migration i see that ef core is creating a table for this, so i see that something is wrong here, can anyone guide me where i am wrong? i dont have any view or table in my db for this, its just a sp that will return results and i want to get them into a model.

1
1
11/13/2019 9:12:42 PM

Popular Answer

ok, i was able to resolve it, here is what i did.

1) changed the code back to the old way and saved it. 2) cleaned solution, and build again. 3) changed the code to the 3.0 version. 4) cleaned solution, and build again.

and now i dont get any errors anymore about adding migration.

0
11/14/2019 4:02:07 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow