How to use AngularJS in ASP.NET MVC and Entity Framework

This post is taken from Dhananjay Kumar.

In short, this post will touch upon:

  • adding an AngularJS library in ASP.NET MVC;
  • reference of AngularJS, bundling and minification;
  • fetching data using the Entity Framework database;
  • returning JSON data from an ASP.NET controller;
  • consuming JSON data in an AngularJS service;
  • using AngularJS service in AngularJS controller to pass data to the view; and
  • rendering data on an AngularJS View

Continue reading

Splitting big Entity model. (EF 5 onwards)

EF5 Onwards Only – The features, APIs, etc. discussed in this page were introduced in Entity Framework 5. Ref: Multiple Diagrams per Model (EF5 onwards)

In this demo I will show you how to split an entity model into multiple diagrams using the new enhanced EF designer.

Sometimes our model can become too large to edit or view.In earlier versions we could only have one diagram per EDMX file.In EF 5.0 we can split the model into more diagrams. Continue reading

Tips to improve Entity Framework Performance

 

  • Avoid to put all the DB Objects into One Single Entity Model

    Entity Model specifies a single unit of work, not all our database. If we have many database objects that are not connected to one another or these(log tables, objects used by batch processes,etc.) are not used at all. Hence these objects are consuming space in the memory and cause performance degrades. So try to make separate entity models of related database objects.

Continue reading

Entity Framework Interview questions

Will there be any issues adding a table without primary keys to a data model?
Every entity must have a key, even in the case where the entity maps to a view. When you use the Entity Designer to create or update a model, the classes that are generated inherit from EntityObject, which requires EntityKey. So, we have to have a primary key in the table to add it to the data model. Continue reading

CRUD operations without mapping the Stored Procedures to the model.

entities.ExecuteStoreCommand("InsertEmployee @ID,@EmpName,@EmpAddress", 
                          ietsParameterID, ietsParameterEmpName, ietsParameterEmpAddress);

————————————————————————————————————————————————————-

var selectData = entities.ExecuteStoreQuery<Employee>("SelectEmployee").ToList();


==> InsertEmployee and SelectEmployee are SP names

ORM and EntityFramework – intro

ORM (Object Relational Mapping) is basically an approach for storing data from domain/entity objects to relational database in an automated way without writing much code. A true ORM is independent of what database server we refer to, the code underlying ORM’s is database independent and can run with any database server having similar database with a structure needed by the application. ORM has 3 main parts: Entity class objects, Relational DB objects and information on how domain objects maps to relational DB objects, i.e., tables, views and storedprocedures. Continue reading