Unable to resolve service for type 'ClassLibrary.ApplicationDbContext'
I have added a Class Library to my solution so that I can use Work Authentication on my ASP.Net Core site. I have been able to add a migration and update database from the PM console. However i am...
View Articlecreating an ef query on an array
I have a Poco class called Product. I also have an array which contains ids of Products which I would love to find. I want a way I can write a single query that would help find Products based on the...
View ArticleThrowing Errors System.InvalidOperationException No service for type and...
I know I have made this issue. I was having issues with my project. Mostly in the migrations as I had stuffed it up. That's fine I am new to this. I forgive myself.To fix this. I decided to create...
View Articlesending DataReader to IEnumerable
What is the best way to send the Datareader to IEnumerable <TABLE> model view page?
View ArticleHow to return multiple result set from EF query
when we use inline sql then we can write sql in such a way as a result it return multiple result set hitting db once time. for exampleselect * from department;select * from employeehere i use semicolon...
View ArticleEF Exception:The context cannot be used while the model is being created
I'm trying to crate database depening on class variables.My classes are defined asusing System; using System.Collections.Generic; using System.Linq; using System.Web; namespace...
View ArticleEF-6 Code First Table Valued Function
Hi,I have built an Entity Framework-6 using Code first and I created a Stored Function which returns a table in the MS-SQL database. How will I be able to reflect the Table-Valued Function in Entity...
View ArticleReturn type for Linq Query
I have a service where by i would like to call the function below. And for the life of me I cant work out what the correct return type should be. I DONT want to create a object class that has the the...
View Articlemapping domain entities to dto's
I have a complex dto that consists of records from 4 tablespublic class AggregateDto { public OrganisationDto Organisation { get; set; } public List<Meter.MeterDto> Meters { get; set; }...
View ArticleNuGet is causing compatibility issues inside my asp.net mvc project when i...
I have the following:-Visual studio 2012 professional. Asp.net MVC 4 web application. 2 .EDMX files representing 2 SQL server 2008 r2 databases. Now my asp.net mvc web application was working well. but...
View ArticleData from a SQL Database
Hi Folks,i have a SQL (Express) Database and I like to use it in my MVC Web App. Sorry, all for me is new. I´m learning building up websites. The normal way I connect into my database, is with username...
View ArticleSQL column not found when using parameters.
Hello,I have the code below to look up a user name. I am trying to use parameters to strengthen against SQL injections. When I run the code below, I get the error: ERROR [42S22] [IBM][System i...
View ArticleIs EF Necessary?
Hi!I'm (finally) moving from WebForms to .Core.I'm using a current project from work as a test. This project is using a 3rd party SQL Server database. It's rather large and complicated, and when one...
View ArticleHow to include Data from Table Above
Not quite sure how to explain this please bear with me.I have a table Client.Table Client has a relationship one to many with Sites.Sites has a relationship one to many with Jobs.In Jobs I want to add...
View Articlepopulating drop down list using EF6
I am trying to upgrade my site to asp.net.identity, but having problems almost every step. I have a simple drop down that just displays a list of states for the user to select from. There are several...
View ArticleRelationship between 2 classes
Hi I have 2 classes . How i can create CountryId as Foreign Key in States Classpublic class Country { [Key] public int CountryId { get; set; } public string CountryName { get; set; } } public class...
View ArticleDbContext.Create()
I am new to Entity Framework & trying to learn, have a basic question. Can we create another DbContext.Create() before savingChanges to already existing Context??
View ArticleProblem in Linq query with lamba expression
i try to fetch all employee from tblEmployee table based on department name where depart_ref_id and emp_ref_id is stored on tblEmpOffInfo1- tblEmployee.cspublic class tblEmployee { public int ID { get;...
View ArticleStored Procedure to get one on in a row on a grid
How could I write a store procedure to get one cell in a row on a grid?
View ArticleHow to manually define DBContext code snippet for table without primary keys?
Hello,I followed these instructions ( https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-db ) to automatically create database models/entity classes and the DBContext class,...
View Article