Right now i have a model-first
approach with EDMX
model in my project. But how can i work without EDMX
file and be able to import stored procedures signatures form database as well as make updates of my entities when database has been changed ?
I think that you are looking for the (misnamed) "Code First" using "Reverse Engineering" to create your code from a database. http://haroldrv.com/2015/04/using-entity-framework-code-first-from-database/ . "Database First" still uses EDMX mapping files which many find to be problematic to work with and are no longer used in the latest EF Core 1 (formerly EF 7).
As far as mapping the stored procedures to entities, this MSDN article https://msdn.microsoft.com/en-us/data/dn468673 shows how. I do not believe there is an automatic way to pull in the stored procedure signatures like you can with the tables themselves.
modelBuilder
.Entity<Blog>()
.MapToStoredProcedures(s =>
{
s.Update(u => u.HasName("modify_blog"));
s.Delete(d => d.HasName("delete_blog"));
s.Insert(i => i.HasName("insert_blog"));
});
You can also just call stored procedures directly without the mapping as below.
var blogs = context.Database.SqlQuery<Blog>(
"getBlogs @param1", new SqlParameter("param1", param1)
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.