Web API CRUD Operations Using Asp Net MVC and Entity Framework

Поделиться
HTML-код
  • Опубликовано: 22 янв 2025

Комментарии • 315

  • @CodAffection
    @CodAffection  7 лет назад +9

    goo.gl/RFY5C2 : Subscribe to CodAffection
    goo.gl/DSSHtV : Mvc CRUD Operation Using Pop Up Windows
    goo.gl/zkoWSg : jQuery Ajax CRUD in Asp.Net MVC
    goo.gl/bPcyXW : Buy me a Coffee

    • @friedrichvillegasmurillo9775
      @friedrichvillegasmurillo9775 3 года назад

      i got lost on 17:38 because i couldn't find the reference to ReadAsAsync
      'System.Net.Http.HttpContent' does not contain a definition for
      'ReadAsAsync' and no extension method 'ReadAsAsync' accepting a
      first argument of type 'System.Net.Http.HttpContent' could be
      found (are you missing a using directive or an Assembly reference?)

  • @PraveenKumar-ft2kr
    @PraveenKumar-ft2kr 5 лет назад +1

    Just 45min and two technologies are done. Best one 👌👌👌👌

    • @CodAffection
      @CodAffection  5 лет назад

      thanks for the wonderful feedback.

  • @KhalidAfridi1
    @KhalidAfridi1 2 года назад +2

    Thank you so much. Now I know how to use API in MVC Project using Entity Framework. Thumbs Up👍

  • @mariojosuecastro303
    @mariojosuecastro303 10 месяцев назад +1

    Outstanding tutorial, pretty straightforward and clear.
    Thank you for sharing your knowledge.
    Greetings from Guatemala!! New subscriber here!!

  • @tsheposepadile
    @tsheposepadile 4 года назад +2

    One of the best tutorials ever.

  • @yerriswamygm5328
    @yerriswamygm5328 Год назад +1

    In a Simple way, you explained
    Thank u so much

  • @Sam-su4sk
    @Sam-su4sk 3 года назад +1

    I like that you show the result before the bullshit that I have to learn

  • @mgmghtay5264
    @mgmghtay5264 Год назад +1

    It is really helpful for all beginner.Thank you so much.

  • @JagdishJ666
    @JagdishJ666 5 лет назад +1

    No doubt, preety straight and simple example to understand Web API CRUD

    • @CodAffection
      @CodAffection  5 лет назад +1

      thanks for your wonderful feedback !.

  • @prernapriyanka7455
    @prernapriyanka7455 4 года назад +1

    awasome bro explain very well

  • @muhammedalitunc219
    @muhammedalitunc219 3 года назад +3

    It was one of my most precious 45 minutes. Thank you :)

  • @awaisahmadsiddiqi6505
    @awaisahmadsiddiqi6505 7 лет назад +3

    @17:55
    i got the following error.
    not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
    what to do?

  • @karenmoralesmarquez5270
    @karenmoralesmarquez5270 4 года назад

    I’m trying to do it right now and I have an error when trying to connect the controller at 7:01 minutes . I have an error that pops saying “There was an error running the selected code generator: ‘Could not load file or assembly ‘Entity Framework, Version =5.0.0.0, Culture = neutral, PublicKeyToken =b77a5c561934e089’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x8013040)’
    What can I do?

  • @ratna709
    @ratna709 3 года назад +2

    Absolutely what I needed. Thanks so much 👍🏻

  • @pulivarthisathyasai9747
    @pulivarthisathyasai9747 7 лет назад +1

    Great job....i liked to learn mvc from ur tutorials videos...i am a beginner and i am expecting more realtime examples like this.....

  • @seethalakshmiraman8182
    @seethalakshmiraman8182 3 года назад +1

    Why are we converting id.tostring() in mvc for calling getemployee(id) from api?

  • @chargershogun1215
    @chargershogun1215 6 лет назад +5

    what a great tutorial, you have helped me a lot, it's the best tutorial I've seen, thank you very much!!

    • @CodAffection
      @CodAffection  6 лет назад +1

      thanks for the comment. Glad you found the video helpful.
      If you have any topic to be discussed related to Web API or ASP.NET MVC, please reply here.

  • @ramunagaraju
    @ramunagaraju 2 года назад +1

    This video is awesome,really helpful. Thank you

  • @justplay678
    @justplay678 3 года назад +2

    This helped me alot. Thanks

  • @alagarkarthik2346
    @alagarkarthik2346 6 лет назад +1

    Good help full example of Crud operation. Thanks

    • @CodAffection
      @CodAffection  6 лет назад +1

      Glad you found the video helpful.

  • @sulfathshajahan.111
    @sulfathshajahan.111 3 года назад +1

    Very helpful tutorial with apt explanation. Thanks

  • @sivaanjaneya9360
    @sivaanjaneya9360 5 лет назад +1

    Thank you so much for giving more information.......
    I have good support for this video...

    • @CodAffection
      @CodAffection  5 лет назад +1

      thanks for your wonder full feedback.

  • @BebakIshq
    @BebakIshq 3 года назад +1

    Fantastic man, very nicely explained. Thanks

  • @Gadaff1
    @Gadaff1 9 месяцев назад +1

    Did you make Reset button to work?

  • @shamitravel
    @shamitravel 5 лет назад +7

    Huge respect

    • @CodAffection
      @CodAffection  5 лет назад

      Thanks for your wonderful feedback.

  • @tatianav1883
    @tatianav1883 6 лет назад

    The best video on this topic. Thank u!

  • @vidyadhartanksale1892
    @vidyadhartanksale1892 4 года назад +1

    Thank you very much for you are providing this important information

  • @sivaanjaneya9360
    @sivaanjaneya9360 5 лет назад +1

    Thanks for giving more information in webapi curd operations......

  • @jimishshah2779
    @jimishshah2779 3 года назад

    having error at 30:57
    Error CS1503 Argument 2: cannot convert from 'MVC.Models.mvcEmployeeModel' to 'System.Net.Http.HttpContent' MVC

  • @ramyasrinivasan6774
    @ramyasrinivasan6774 3 года назад +2

    Thank you so much !! Kindly upload three tier architecture in web api. Please.

  • @learnforever1801
    @learnforever1801 5 лет назад

    Thank you so much from Vietnam

  • @willyeruiz15
    @willyeruiz15 4 года назад +2

    My friend, how do you create a constructor in the static class GlobalVariables? Is possible that?

    • @nareshkumar-kf7te
      @nareshkumar-kf7te 4 года назад +1

      error is static classes cannot have instance constructors.how can i slove this

    • @brendonanderson8673
      @brendonanderson8673 4 года назад +1

      @@nareshkumar-kf7te static GlobalVariables() { }

  • @yogeshbisht5897
    @yogeshbisht5897 7 лет назад

    Really its very helpful vedio using CURD opertion using web api..thanks.

  • @sultanatasneem1787
    @sultanatasneem1787 4 года назад

    Wow. great 👌. Thank you so much 💖

  • @Arbupa
    @Arbupa 5 лет назад

    COULD SOMEONE HELP ME?
    On minute 19:28 I have an exception error: "JsonSerializationException: Cannot deserialize the current JSON object..."
    The error occurs on the line:
    empList = response.Content.ReadAsAsync().Result;

    • @CodAffection
      @CodAffection  5 лет назад

      did you tried this : stackoverflow.com/a/21885758/4133590

  • @nguyenalice8051
    @nguyenalice8051 6 лет назад

    I followed the video and finished very well. You have helped me a lot, the best tutorial I've seen, I love CodAffection.

  • @abhishekanand6591
    @abhishekanand6591 6 лет назад

    Great Work man , huge thanks , seriously !

  • @brandonbarquero1660
    @brandonbarquero1660 3 года назад

    Thank you, great tutorial.

  • @edwinnavas4556
    @edwinnavas4556 7 лет назад +12

    The best tutorial I've seen, good job you example is the best example I've seen, only I some question, can I use a Web Services with Entity Framework action ? if you have any example for this kind problem is a good idea you try to explain, my second question is when I made my CRUB I have a item of datetime type, I use a datepicker but I have a problem whit the day when the day is major or equal to 13, I save the day in this format "mm/dd/yy" but when I recive the day in my controller I recive a parameter null, Why can you explain me this please? what I need to do for fix this problem; my last question is How to remove the hour in a field datetime, thank you

    • @Ali786zyx
      @Ali786zyx 6 лет назад +2

      seems that your date and month are mixed up. Your computer may be receiving in USA format "mmddyyyyy" and the control might be sending in english format "ddmmyyyy" or vice versa.

  • @rjc12481
    @rjc12481 5 лет назад

    Very nice for beginners. Thanks for this awesome tutorial.

  • @vivekdesai8500
    @vivekdesai8500 6 лет назад

    Great tutorial! Please keep uploading on such informative topics. Thank you

  • @noellangcauon7133
    @noellangcauon7133 4 года назад

    Thanks bro! very helpful!

  • @arslanjappa4335
    @arslanjappa4335 6 лет назад +1

    stunning crud operations sir.

    • @CodAffection
      @CodAffection  6 лет назад

      thanks for the kind words.

    • @abhaykumarsharma5672
      @abhaykumarsharma5672 3 года назад

      @@CodAffection I am getting socket exception : connect was forcibly closed .. please help me how to resolve

  • @rahulchugh6694
    @rahulchugh6694 6 лет назад

    Very useful and great explanation sir . thank you please upload more videos.

  • @codyman7418
    @codyman7418 6 лет назад

    wonderful. this tutorial is very helpful, understandable and well explained. great job

    • @niranjandas9642
      @niranjandas9642 5 лет назад

      So many adds, overal it's very easy to understand.

  • @ishratshaikh70
    @ishratshaikh70 2 года назад +1

    @CodAffection can you please share which nuget packages you have added in WebApi & Mvc, coz after completing project data is not updating & deleting from front end. Or anyone can please. Preparing for interview.

  • @bharathsiddu5284
    @bharathsiddu5284 5 лет назад

    great tutorial , i never found like this one, if we have knowledge on concept we never feel work pressure, keep doing more videos, my humble request is to do a video on django framework similary by taking like this small project , thanks a lot

    • @CodAffection
      @CodAffection  5 лет назад +1

      thanks for sharing your thoughts here.
      I'm working on my python. hopefully django framework tutorial are on the way.
      I would be waiting for your feedback once it is done.

  • @AMRashedMahamud1320
    @AMRashedMahamud1320 6 лет назад

    Thanks for the demonstration.

  • @skkuvind
    @skkuvind 5 лет назад

    I am getting error on timestamp: 09:28 of your video.
    Error:
    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Unexpected error occurred inside a LocalDB instance API method call. See the Windows Application event log for error details.
    )

    • @CodAffection
      @CodAffection  5 лет назад

      Please check this post : stackoverflow.com/a/1393125/4133590

  • @betoag04
    @betoag04 3 года назад

    thank you so much, Master!!! take care...

  • @tricman10
    @tricman10 6 лет назад

    Great tutorial as always!

  • @Probeh.
    @Probeh. 7 лет назад

    Great Tutorial Man Awesome Job!

  • @happie88
    @happie88 6 лет назад

    This is what I'm looking for. Just subcribed and iked... thanks man! :)

  • @iwaksate1087
    @iwaksate1087 5 лет назад

    Excellent, great tutorial

  • @Inyector
    @Inyector 4 года назад +1

    Great Video.

  • @snehalkolhe2416
    @snehalkolhe2416 6 лет назад

    Very helpful, keep the good work :)

  • @ronaldello97
    @ronaldello97 3 года назад

    I can't call the HTTP method from the WebAPI project in my WebApp thorugh implementing the insert operation" in my WebApp employee controller. I cannot define the GlobalVariables (it doesn't show up). I assume it is because my WebAPI project (which in my case communicates with my MS SQL server db using EF Migrations) is a separate solution from the WebApp. You seem to have both the WebAPI and the Website in 1 solution. Any advice?

  • @davidng3675
    @davidng3675 3 года назад

    Good tutorial, thanks bro

  • @frindestec1216
    @frindestec1216 5 лет назад +1

    What do you think about the use of Migration database and can you explain

  • @kinjalhingu6619
    @kinjalhingu6619 7 лет назад

    Thank u for this video..helped a lot

  • @GabrielMendezz
    @GabrielMendezz 5 лет назад +5

    Instead of : webAPIClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json)"));
    USE:
    webAPIClient.DefaultRequestHeaders.Add("Accept", "application/json;odata=verbose");
    It works!

  • @saurabhmishra-rv7sw
    @saurabhmishra-rv7sw 2 года назад

    Nice content Sir

  • @mauriciohernandezcabrera9413
    @mauriciohernandezcabrera9413 5 лет назад

    Hey dude, thanks a lot. Awesome video, great tutorial. It was so useful to me. And from scratch. THANKS!!! :)

  • @kenrk3757
    @kenrk3757 5 лет назад

    Awesome, Thank you!

  • @alicenguyen7355
    @alicenguyen7355 6 лет назад +1

    So great thank you.

  • @amirsaleem4935
    @amirsaleem4935 4 года назад

    Nice work brother.

  • @rajeshrohan9435
    @rajeshrohan9435 5 лет назад +2

    Nice explanation for startup! Css doesn't work have copied from project download link, but for my case Create New open in same window itself not as popup. Please help.

  • @AbdulRehman-bn1qn
    @AbdulRehman-bn1qn 6 лет назад +1

    Line 18: empList = response.Content.ReadAsAsync().Result;
    .
    Error: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.IEnumerable`1[Mvc.Models.mvcEmployeeModel]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
    Please Fix it.

    • @danishhabib3495
      @danishhabib3495 6 лет назад

      Solution: Add a reference to System.Net.Http.Formatting.dll. This assembly is also available in the C:\Program Files\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies folder.
      The method ReadAsAsync is an extension method declared in the class HttpContentExtensions, which is in the namespace System.Net.Http in the library System.Net.Http.Formatting.
      Reflector came to rescue!

  • @oldanandiansassociationchi1157
    @oldanandiansassociationchi1157 6 лет назад

    Great Tutorial.this is the best

    • @CodAffection
      @CodAffection  6 лет назад

      Thank you for the wonderful feedback! :) I'm humbled.

  • @tecint
    @tecint 4 года назад

    You did good, congrats

  • @aethenwulf4757
    @aethenwulf4757 5 лет назад +1

    Great tutorial, but i have one question about your post obj, how can i make it accept post array obj?

  • @vijiajai4879
    @vijiajai4879 6 лет назад +4

    Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.IEnumerable`1[MVC.Models.MVCEmployeeModel]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly
    Error is coming

    • @TouhidulFahim1
      @TouhidulFahim1 6 лет назад

      Same Error In my application :(

    • @shubhamaditya7481
      @shubhamaditya7481 6 лет назад +2

      Add web api employee class name in the following line GlobalVariables.WebApiClient.GetAsync("Employees").Result

    • @hrishikeshbagchi6116
      @hrishikeshbagchi6116 5 лет назад

      @@shubhamaditya7481 Thanks bro

    • @onajonaj7381
      @onajonaj7381 5 лет назад

      @@shubhamaditya7481 Can you tell me where, I don't understand where I nedd to add? Please :(

    • @otavioneto9766
      @otavioneto9766 5 лет назад

      @@shubhamaditya7481 Obrigado, me ajudou muito

  • @hogramac
    @hogramac 6 лет назад

    Very good Video. Thanks !

    • @CodAffection
      @CodAffection  6 лет назад

      My pleasure & Wish You Good Luck :)

  • @supriyagawad4381
    @supriyagawad4381 5 лет назад +3

    Great tutorial, no doubt about it.
    But one question to ask
    How to connect Oracle database instead of SQL ?

  • @raymondagbunag851
    @raymondagbunag851 7 лет назад

    Teacher, thank you so much!

  • @navaneetspatil3038
    @navaneetspatil3038 5 лет назад +1

    Superbly explained each steps, Great work. Can you please help me that how to use stored procedures using entity framework in web api?

  • @anilsah9498
    @anilsah9498 7 лет назад

    Very helpful video,i liked very much.Please upload more videos on asp.net mvc.
    Q1.How to use dapper in web Api with repository model ? Plz help me out.

    • @CodAffection
      @CodAffection  7 лет назад

      Dapper ORM in Asp.net MVC : ruclips.net/video/bKB0TV_XbLA/видео.html

  • @usamadanish1873
    @usamadanish1873 6 лет назад

    Good job by CodAffection Thankxx

  • @juliocsoria1512
    @juliocsoria1512 5 лет назад

    Tu video es genial! gracias!

  • @snehalnawale1930
    @snehalnawale1930 3 года назад

    If suppose their are 11 table then we need to create 11 controllers in mvc and in api also?

  • @yash2154
    @yash2154 3 года назад

    Hi for some reason when i submit the form, the values are not getting added in the database

  • @muhammadsadiq8621
    @muhammadsadiq8621 4 года назад

    nice kafi acha tha

  • @shinek1623
    @shinek1623 4 года назад

    Super tutorial

  • @Azaad_duniaa
    @Azaad_duniaa 6 лет назад +4

    very help full video but i found error 'No MediaTypeFormatter is available to read an object of type 'IEnumerable`1' from content with media type 'text/html'. can u help??
    '

    • @AxellBismarck
      @AxellBismarck 6 лет назад

      @Vicky Heartland I can't believe it. :)

    • @RahulPal-ev7pb
      @RahulPal-ev7pb 4 года назад

      Hello i reslove this error suceessfully , you just need to correct port number => new Uri("localhost:44345/api/"); here 44345 is api port number in your localhost just like in your local webapi project mention correct port number and it will work..........

  • @tahirali7961
    @tahirali7961 7 лет назад

    Sir you are best

  • @muhammedyilmaz2907
    @muhammedyilmaz2907 4 года назад

    thanks for tuto.. Good job. I think 142k views and just 1k likes is injustice.

    • @CodAffection
      @CodAffection  4 года назад

      Thanks for the wonderful comment.

  • @anbuanbu6591
    @anbuanbu6591 5 лет назад +1

    Hi I have one doubt... If you create table foreign key table data also.
    How to restrict this?

  • @travelwithmms6937
    @travelwithmms6937 5 лет назад

    I have tried multiple of time the same code you have written, but it threw exception :
    System.Net.Http.UnsupportedMediaTypeException: 'No MediaTypeFormatter is available to read an object of type 'IEnumerable`1' from content with media type 'text/html'.'

  • @onur5717
    @onur5717 6 лет назад +5

    Hello ,
    can you add login and logout to this application?

  • @ajithkumar-iw2ix
    @ajithkumar-iw2ix 3 года назад

    in index.cshtml class some error showing System.NullReferenceException: 'Object reference not set to an instance of an object.'
    excepation Throw
    can you tel how can i short out this error

  • @marktabor6457
    @marktabor6457 5 лет назад

    For delete why we are writing method in javascript as well as in controller action method ?

    • @CodAffection
      @CodAffection  5 лет назад

      yes, you can directly call to Web API method instead of mvc action method. if you don't have any thing to do in mvc. happy coding.

  • @isa91971
    @isa91971 2 года назад

    You are good man

  • @The-oz3hb
    @The-oz3hb 6 лет назад +2

    20:40
    No connection could be made because the target machine actively refused it 127.0.0.1:64028
    Line 18: HttpResponseMessage response = GlobalVariables.WebApiClient.GetAsync("Employee").Result;
    teacher help me!!

    • @alepaulette2604
      @alepaulette2604 4 года назад +1

      i have this same problem, did u find a solution?😩

  • @heysocks473
    @heysocks473 3 года назад

    hi, may i know about the database, do we need to do another project or still in the same solution with mvc and dummy project?

  • @shining174
    @shining174 7 лет назад

    Thank you very much.

  • @easylearnwithraksha2229
    @easylearnwithraksha2229 2 года назад

    Hi,
    I am getting exception,
    Server Error in '/' Application.
    Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.IEnumerable`1[WebApiInMVC.Models.EmployeeMVC]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
    To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
    Path 'Message', line 1, position 11.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.IEnumerable`1[WebApiInMVC.Models.EmployeeMVC]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
    To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
    Path 'Message', line 1, position 11.
    Source Error:
    Line 17: IEnumerable empList;
    Line 18: HttpResponseMessage response = GlobalVariables.WebApiClient.GetAsync("Employee").Result;
    Line 19: empList = response.Content.ReadAsAsync().Result;
    Line 20: return View(empList);
    Line 21: }
    Please help me to resolve this.
    Thnaks in advance!

  • @ariannehernandez9680
    @ariannehernandez9680 5 лет назад +1

    for some reason I encountered an error while doing this project
    when I type localhost:60502/Employee in the browser,. it shows the following error..
    I don't know what's the issue..
    Server Error in '/' Application.
    No MediaTypeFormatter is available to read an object of type 'IEnumerable`1' from content with media type 'text/html'.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.Net.Http.UnsupportedMediaTypeException: No MediaTypeFormatter is available to read an object of type 'IEnumerable`1' from content with media type 'text/html'.
    Source Error:
    Line 16: IEnumerable empList;
    Line 17: HttpResponseMessage response = GlobalVariables.WebApiClient.GetAsync("Employee").Result;
    Line 18: empList = response.Content.ReadAsAsync().Result;
    Line 19: return View(empList);
    Line 20: }
    Source File: C:\Users\EdgeTech1\source
    epos\WebApi\Mvc\Controllers\EmployeeController.cs Line: 18
    Stack Trace:

    • @stevensnow2089
      @stevensnow2089 4 года назад +1

      I had this error and it was because I had the wrong URI in GlobalVariables. Make sure your URI is pointing to the Web API. You can get your project URI by right clicking on WebAPI project -> Properties -> Web.

    • @kamalchannel6647
      @kamalchannel6647 2 года назад

      @@stevensnow2089 yes and thanks for your reply. It worked after I put / in baseaddress.

  • @anbuanbu6591
    @anbuanbu6591 6 лет назад

    Which method is best for crud in MVC application... Normal CRUD or jQuery Ajax CRUD ???

    • @CodAffection
      @CodAffection  6 лет назад

      depends upon your requirement.
      Normal crud operation includes reloading of the page after form submission in case of jQuery Ajax CRUD we can avoid that.

  • @jj-gh1fl
    @jj-gh1fl 3 года назад

    Excellent

  • @Sieupham301
    @Sieupham301 7 лет назад

    Greate. Good man