Results 1 to 2 of 2

Thread: I need some basic help with Entity Framework code first

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2018
    Posts
    42

    Post I need some basic help with Entity Framework code first

    Hi all,

    I'm developing an application under visual studio using C#.

    For the database I'm using Entity Framework with code first, and now I've create the database structure, table relations and I can insert registers.

    The problem now is I can't find any documentation/tutorial that explain how to retrieve data from the database, delete entries, modify registers and all this.

    I know that for someone that know how to do it, it must be very easy, but althought I'd now how to do it in pure SQL I'm unable to implement it.

    What I need is the simpliest thing xD

    -SELECT * from table where field = value (and then iterate the items retrieves that matches the condition and retrieve data)
    -DELETE * from table where field = value

    If someone knows a simple tutorial or similar that explain it, I would thank a lot.

    Regards

  2. #2
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

    Re: I need some basic help with Entity Framework code first

    https://docs.microsoft.com/en-us/ef/ef6/querying/ should give you an idea of how to query the model.

    Modifying data is a matter of retrieving the data you want to modify, probably by using a query, and then calling the .SaveChanges method of your context.

    IIRC the context should also offer a .Remove method, simply pass in the item you wish to remove and call .SaveChanges and it should be deleted.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width