简体   繁体   中英

EF6 Change mapping from table to stored procedure

I have one application which is finished and working. But recently arrived security instruction that every DB access have to be done via stored procedures and it applies for users and applications too.

This application run at ASP .NET MVC framework (version 4) and have ORM declared this kind of way

[Table("TableName1")]
public class TableName1
{
    [Key]
    public int ID { get; set; }

    [MaxLength(250), Index("IX_NameCountry", 1, IsUnique = true, IsClustered = false)]
    public string Name { get; set; }
    ...
}

public ICollection<TableName2> TableName2
        {
            get
            {
                return Database.SqlQuery<TableName2>("SELECT * FROM dbo.TableName2").ToList();
            }
        }

Im beginner with MVC and EF, but i found that EF6 support stored procedure mapping. What is the easiest way of rewriting the application ? I would very thankful for one example how i can remap the table mapping :-)

thank you

See: How to call Stored Procedure in Entity Framework 6 (Code-First)?

As a side, depending on your application size this could be a huge undertaking to something that sounds like a knee jerk reaction by someone in response to something.

I would tactfully respond by explaining it would be better to spend resources for you (and your team) to review the existing code base where you tough the DB and fix any security holes. Request your app to be pen tested.

There could be risk to the business / users because the bugs this could potentially introduce - think of all those LINQ Expressions you will have to translate to SQL :)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM