Modelling polymorphic associations database-first vs code-first

I personally stick with Database first when using EF on any schema that is this level of complexity. I have had issues with complex schemas in regards to code first. Maybe the newer versions are a little better, but worrying how to try and code complex relationships seems less straight forward then allowing the engine … Read more

How can I call a SQL Stored Procedure using EntityFramework 7 and Asp.Net 5

I hope that I correctly understand your problem. You have existing STORED PROCEDURE, for example dbo.spGetSomeData, in the database, which returns the list of some items with some fields and you need to provide the data from Web API method. The implementation could be about the following. You can define an empty DbContext like: public … Read more

Is there an Entity Framework 7 Database-First POCO Generator?

In the latest bits it is possible to use the dnx command prompt and PowerShell commands to do this, yes Scaffold-DbContext ‘<connectionString>’ EntityFramework.MicrosoftSqlServer or dnx ef dbcontext scaffold “<connectionString>” EntityFramework.MicrosoftSqlServer or (from EF Core RC2) dotnet ef dbcontext scaffold “<connectionString>” Microsoft.EntityFrameworkCore.SqlServer You must install the Microsoft.EntityFrameworkCore.Tools package for the command to work.

ASP.NET Identity with EF Database First MVC5

It should be possible to use the identity system with POCO and Database First, but you’ll have to make a couple of tweaks: Update the .tt-file for POCO generation to make the entity classes partial. That will make it possible for you to supply additional implementation in a separate file. Make a partial implementation of … Read more

How to update record using Entity Framework 6?

You’re trying to update the record (which to me means “change a value on an existing record and save it back”). So you need to retrieve the object, make a change, and save it. using (var db = new MyContextDB()) { var result = db.Books.SingleOrDefault(b => b.BookNumber == bookNumber); if (result != null) { result.SomeValue … Read more

Code-first vs Model/Database-first [closed]

I think the differences are: Code first Very popular because hardcore programmers don’t like any kind of designers and defining mapping in EDMX xml is too complex. Full control over the code (no autogenerated code which is hard to modify). General expectation is that you do not bother with DB. DB is just a storage … Read more