There are many people that have asked this question before on SO. For the last 3 hours I have sequentially tried each solution, and I get the same No executable found matching command "dotnet-ef" each time. I'd like to understand how to run the
After updating an existing project to ASP.NET Core 1.1 and Entity Framework Core 1.1 using this tutorial I tried to execute "Add-Migration MigrationName" in Package Management Console but got an error: Startup project 'src\ProjectName' is an ASP
Please help me to convert this SQL statement to Linq in C#: string cmd = "SELECT * FROM dbo.Personnel WHERE (dbo.Personnel.FName LIKE @FName + '%' AND dbo.Personnel.LName LIKE @LName +'%')"; if (objPPersonnel.PersonnelCode != 0) { cmd += "A
I Create Two class in Models folder Like this: Material.cs: public class Material { public int MaterialId { get; set; } public string Name { get; set; } public virtual ICollection<Project> Project { get; set; } } Project.cs: public class Project { [
My organization needs to have a shared database, shared schema multitenant database. We will be querying based on TenantId. We will have very few tenants (less than 10) and all will share the same database schema with no support for tenant-specific c
When using entity framework, is it bad practice to inject the repository into a controller? For example if I have a service: public class DogService { IMyDbContext _myDbContext; public DogService(IMyDbContext myDbContext) { _myDbContext = myDbContext
I am trying to pass hidden field value from view to controller by doing the following @Html.HiddenFor(model => model.Articles.ArticleId) and also tried <input type="hidden" id="ArticleId" name="ArticleId" value="@M
I have one function that requires an active dbContext that is used in multiple places. In some places the DbContext already exists so I pass it in and use it if it does: public void DoStuff(){ using (var db = new dbContext()){ DoThings(db); db.SaveCh
I'm creating a CRUD with Asp.net and Entity Framework. When I try get LastModification DateTime for same User, I get two differents values. I don't know why I get two differents values for same Datetime.There is a difference of milliseconds in both d
I have article and author classes. Fetch articles like so and map entity to model: public List<Model.Article> GetArticleList() { using (var db = new ArticlesContext()) { return db.Articles.Select(t => new Model.Article() { Author = MapUserEntityT
I am new to ASP/EF. I am using ASP 5 and Entity Framework 7 in my personal project. So I am able to create database and tables with code first approach, but all the table names are singular and does not pluralize by default. In my ServerMatrixDemoDB
I am modifying my project to use DBContext instead of ObjectContext. My existing code var query = context.Vehicles.OrderBy("it.VehicleType.VehicleTypeID"). GroupBy("it.VehicleType.VehicleTypeID", "Min(it.ODO_Reading) AS MinRunVehi
My project is a game where users try to predict scores of football matches and are awarded points based off of different criteria. I'm using MVC and Entity Framework. I am trying to create a leaderboard that displays the total score for each user. I'
In my MVC application, a superadministrator can set a queue of tasks such as updating database. So, when an admin adds an update to the queue, the controller starts a new tasks that works in a background. However, when you add a few tasks, the applic
I have a very basic controller, which does a Linq to Entities query and I want to be able to project the results onto a viewmodel using AutoMapper - however I'm getting the error: cannot convert from 'System.Collections.Generic.List<AnonymousType#1>
Full exception: System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> System.Data.SqlClient.SqlException: A transport-level error has occurred when
I really want to be able to use NodaTime in my Entity Framework Code First database projects but haven't found a "clean" way to do it. What I really want to do is this: public class Photoshoot { public Guid PhotoshootId{get; set;} public LocalDa
I've been trying to find the answer to this and haven't had any luck. Assume I have a model that looks something like this: public class A { public int Id {get;set} public ICollection<B> Bs {get;set;} } public class B { public int Id {get;set} publi
The code is listed below , is my code for multimode search in ado.net , i use now entity framework and i dont know how write this perfectly with less code string query = '"SELECT id From user"; if(filter1 != "" || filter2 != "&quo
I have code to retrieve all columns from a entity class against a search criteria. But I want a specific column value instead of complete column values. My code is - Main main; main = repo.Find<Main>(m => m.Code == criteria.code); where Main is e
I am currently building an ASP.net MVC application, which has be broken down into multiple modules (as well as a generic class library). I have implemented a Unit Of Work pattern for my first module. This unit of work class contains a number of diffe
I have just started learning ASP.NET MVC 3 and I am deep trouble deciding the best way to connect to the database for my application. As my application database will be enhance in regular intervals so new tables, columns could be added/removed and ma
Are there any consensus as to what is considered the best method in always maintaining data integrity in Entity Framework. i.e. when adding or deleting entities, how do I make sure the loaded model is the most recent, and that nothing has changed on
I have a table named as EnrollTrainee. I have these columns in my EnrollTrainee Model Class: [Key] public int id { get; set; } public int TraineeID { get; set; } public int TrainerID { ![enter image description here][1]get; set; } public virtual Crea
I'm new to EF but i've managed to set up several entities with relationships etc. Now i need to query the database to return a list of "cases" for the current user. I would normally use a stored procedure for this which i've created however the
I have this code to find the root node of a tree: Guid? currentNode = null; var root = db.RecursiveTrees.Where(x => x.ParentId == currentNode).ToList(); This query returns 0 results. If I run this query I get the expected row returned: var root = db.
Used code first and everything appears to work apart from the below which also worked before when I used ObjectContext and called context.PCBuilds.AddObject(pcBuild) but after switching to DbContext it's giving me the error. EFDbContext context = new
I am using EF 4.1 and was look for a nice workaround for the lack of enum support. A backing property of int seems logical. [Required] public VenueType Type { get { return (VenueType) TypeId; } set { TypeId = (int) value; } } private int TypeId { get
Okay, so I'm new to both EF and LINQ. I have figured out how to INSERT and DELETE but for some reason UPDATE seems to escape my grasp. Here is a sample of my code: EntityDB dataBase = new EntityDB(); Customer c = new Customer { Name = "Test", Ge
I have a sizable legacy MS SQL database where foreign key relationships were never implemented. Is it possible to implement "logical" foreign keys between entities in Entity Framework 4 without there being actual foreign key relationships presen