# Entity Framework

**URL:** https://forum.codewithmosh.com/c/entity-framework/19.md

[Latest](https://forum.codewithmosh.com/latest.md) · [Categories](https://forum.codewithmosh.com/categories.md)

---

## [About the Entity Framework category](https://forum.codewithmosh.com/t/about-the-entity-framework-category/30)

<div class="topic-metadata">

**Author:** [@Mosh](https://forum.codewithmosh.com/u/Mosh)\
**Replies:** 0\
**Last updated:** [October 22, 2020, 10:31pm UTC](https://forum.codewithmosh.com/t/about-the-entity-framework-category/30 "2020-10-22T22:31:19Z")

</div>

---

## [Dependency inject](https://forum.codewithmosh.com/t/dependency-inject/27843)

<div class="topic-metadata">

**Author:** [@Murat3443](https://forum.codewithmosh.com/u/Murat3443)\
**Replies:** 1\
**Last updated:** [July 25, 2024, 7:53am UTC](https://forum.codewithmosh.com/t/dependency-inject/27843 "2024-07-25T07:53:31Z")

</div>

Ive followed all 3 C# courses, entity and mvc. But nowhere did we got the explanation about dependency injection.(Say to me if I’m wrong) Anyone know a good tutorial? For blazor.

---

## [Data Annotations Vs Fluent API](https://forum.codewithmosh.com/t/data-annotations-vs-fluent-api/21154)

<div class="topic-metadata">

**Author:** [@Kimberly](https://forum.codewithmosh.com/u/Kimberly)\
**Replies:** 1\
**Last updated:** [June 29, 2023, 5:10pm UTC](https://forum.codewithmosh.com/t/data-annotations-vs-fluent-api/21154 "2023-06-29T17:10:18Z")

</div>

Hi new to the forum And I’m watching the Entity Framework Lecture I understand Mosh’s concerned with the magic string in the Data annotations but a solution could be to Specify it like this \[ForeignKey(nameof(DataAnn…

---

## [Error after executing Enable-Migration(The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.)](https://forum.codewithmosh.com/t/error-after-executing-enable-migration-the-type-initializer-for-system-data-entity-internal-appconfig-threw-an-exception/20819)

<div class="topic-metadata">

**Author:** [@Parth](https://forum.codewithmosh.com/u/Parth)\
**Replies:** 1\
**Last updated:** [June 15, 2023, 6:27pm UTC](https://forum.codewithmosh.com/t/error-after-executing-enable-migration-the-type-initializer-for-system-data-entity-internal-appconfig-threw-an-exception/20819 "2023-06-15T18:27:07Z")

</div>

PM\> Enable-Migrations A version of Entity Framework older than 6.3 is also installed. The newer tools are running. Use ‘EntityFramework\\Enable-Migrations’ for the older version. Checking if the context targets an exist…

---

## [Database table is not updating after execution throwing exception](https://forum.codewithmosh.com/t/database-table-is-not-updating-after-execution-throwing-exception/20736)

<div class="topic-metadata">

**Author:** [@Parth](https://forum.codewithmosh.com/u/Parth)\
**Replies:** 0\
**Last updated:** [June 10, 2023, 11:20am UTC](https://forum.codewithmosh.com/t/database-table-is-not-updating-after-execution-throwing-exception/20736 "2023-06-10T11:20:04Z")

</div>

Throwing below exception and database table is not updating ,Please help with the solution Unhandled Exception: System.Data.Entity.Infrastructure.DbUpdateException: Unable to update the EntitySet ‘Posts’ because it has …

---

## [Error when update-database migration](https://forum.codewithmosh.com/t/error-when-update-database-migration/1257)

<div class="topic-metadata">

**Author:** [@IbrahimTex](https://forum.codewithmosh.com/u/IbrahimTex)\
**Replies:** 1\
**Last updated:** [October 7, 2022, 2:50am UTC](https://forum.codewithmosh.com/t/error-when-update-database-migration/1257 "2022-10-07T02:50:29Z")

</div>

When tried to create database using entity framework by using ‘update-database’ i face this error PM\> update-database Specify the ‘-Verbose’ flag to view the SQL statements being applied to the target database. Syste…

---

## [Entity Framework many to many joining table entity (CRUD OPERATION)](https://forum.codewithmosh.com/t/entity-framework-many-to-many-joining-table-entity-crud-operation/14984)

<div class="topic-metadata">

**Author:** [@mtahaq](https://forum.codewithmosh.com/u/mtahaq)\
**Replies:** 3\
**Last updated:** [September 21, 2022, 4:41pm UTC](https://forum.codewithmosh.com/t/entity-framework-many-to-many-joining-table-entity-crud-operation/14984 "2022-09-21T16:41:24Z")

</div>

Hello, I am new to Entity Framework, I wanna know how to add updates, or delete data from the Joining table which is automatically created from the code first approach when using many to many relationships between model…

---

## [Introducing Concurrency](https://forum.codewithmosh.com/t/introducing-concurrency/11388)

<div class="topic-metadata">

**Author:** [@Jamie](https://forum.codewithmosh.com/u/Jamie)\
**Replies:** 4\
**Last updated:** [September 3, 2022, 12:45pm UTC](https://forum.codewithmosh.com/t/introducing-concurrency/11388 "2022-09-03T12:45:12Z")

</div>

Ive been reading some articles to introduce Optimistic Concurrency into my application, so if two users are editing a single record they are given options to either lose their changes and reload or save over the current …

---

## [Doing Joins with EF and Repository pattern](https://forum.codewithmosh.com/t/doing-joins-with-ef-and-repository-pattern/13863)

<div class="topic-metadata">

**Author:** [@Jamie](https://forum.codewithmosh.com/u/Jamie)\
**Replies:** 0\
**Last updated:** [July 22, 2022, 10:47am UTC](https://forum.codewithmosh.com/t/doing-joins-with-ef-and-repository-pattern/13863 "2022-07-22T10:47:46Z")

</div>

Im following the tutorial for EF6 along with the PlutoContext examples I have generated the default code with an IRepository etc and then my Products class implements that class + my IProductRepository for any additiona…

---

## [Adding column in aspNet Identity aspNetUserRoles, and reflect changes with entityframework DB First](https://forum.codewithmosh.com/t/adding-column-in-aspnet-identity-aspnetuserroles-and-reflect-changes-with-entityframework-db-first/13510)

<div class="topic-metadata">

**Author:** [@coderNet2021](https://forum.codewithmosh.com/u/coderNet2021)\
**Replies:** 0\
**Last updated:** [July 7, 2022, 8:53am UTC](https://forum.codewithmosh.com/t/adding-column-in-aspnet-identity-aspnetuserroles-and-reflect-changes-with-entityframework-db-first/13510 "2022-07-07T08:53:37Z")

</div>

I have a question regarding the Identity tables in Asp.NET Identity , especially aspnetUserRoles and Entity framework Database First Approach: is there a way to add a column in AspNetUserRoles and reflect the changes in…

---

## [How to extend the Repository class](https://forum.codewithmosh.com/t/how-to-extend-the-repository-class/11872)

<div class="topic-metadata">

**Author:** [@Jamie](https://forum.codewithmosh.com/u/Jamie)\
**Replies:** 1\
**Last updated:** [April 12, 2022, 5:05pm UTC](https://forum.codewithmosh.com/t/how-to-extend-the-repository-class/11872 "2022-04-12T17:05:38Z")

</div>

I’ve followed the pattern introduced in the EF 6 course. I would like to have a Generic method to run across certain tables. Currently the IRepository interface/class makes all the methods listed in the interface availa…

---

## [Updating a single record](https://forum.codewithmosh.com/t/updating-a-single-record/11334)

<div class="topic-metadata">

**Author:** [@Jamie](https://forum.codewithmosh.com/u/Jamie)\
**Replies:** 5\
**Last updated:** [March 18, 2022, 11:48am UTC](https://forum.codewithmosh.com/t/updating-a-single-record/11334 "2022-03-18T11:48:21Z")

</div>

I am using the Entity Framework 6 tutorials. I have a method called ChangeDate (for example) public void ChangeDate (Customer c) { c.DateModidifed = datetime.Now(); } In my unit of Work i call this method as \_uow…

---

## [Update records without the Update method](https://forum.codewithmosh.com/t/update-records-without-the-update-method/11265)

<div class="topic-metadata">

**Author:** [@Jamie](https://forum.codewithmosh.com/u/Jamie)\
**Replies:** 1\
**Last updated:** [March 15, 2022, 6:05am UTC](https://forum.codewithmosh.com/t/update-records-without-the-update-method/11265 "2022-03-15T06:05:36Z")

</div>

I have been going through the EF 6 tutorials and one comment that stands out is not to create an Update method. When i search around everyone else has the Update method so imagine i have the below scenario: public stat…

---

## [Entity framework 6.0 get max length of field](https://forum.codewithmosh.com/t/entity-framework-6-0-get-max-length-of-field/11086)

<div class="topic-metadata">

**Author:** [@imichalev](https://forum.codewithmosh.com/u/imichalev)\
**Replies:** 0\
**Last updated:** [March 5, 2022, 7:27pm UTC](https://forum.codewithmosh.com/t/entity-framework-6-0-get-max-length-of-field/11086 "2022-03-05T19:27:24Z")

</div>

Hello, I am try to know what is the max lenght in DB for some nvarchar filed, befor use them. Is theare are easy way to get this value programmly ?

---

## [Code First: Could not find file error after enable-migrations](https://forum.codewithmosh.com/t/code-first-could-not-find-file-error-after-enable-migrations/7114)

<div class="topic-metadata">

**Author:** [@abalfoort](https://forum.codewithmosh.com/u/abalfoort)\
**Replies:** 8\
**Last updated:** [February 22, 2022, 1:32pm UTC](https://forum.codewithmosh.com/t/code-first-could-not-find-file-error-after-enable-migrations/7114 "2022-02-22T13:32:57Z")

</div>

When following the video “Demo -Code-first Workflow” I got the following error when running enable-migrations in the Package Manager Console: PM\> enable-migrations Checking if the context targets an existing database...…

---

## [Repository pattern: Update](https://forum.codewithmosh.com/t/repository-pattern-update/8717)

<div class="topic-metadata">

**Author:** [@galloste](https://forum.codewithmosh.com/u/galloste)\
**Replies:** 1\
**Last updated:** [December 4, 2021, 9:44am UTC](https://forum.codewithmosh.com/t/repository-pattern-update/8717 "2021-12-04T09:44:18Z")

</div>

Mosh suggests to not insert the Update method in Repository Pattern, maybe I have lost something, but how can I update data without that method?

---

## [Entity Framework 6 and sql server filestream](https://forum.codewithmosh.com/t/entity-framework-6-and-sql-server-filestream/7775)

<div class="topic-metadata">

**Author:** [@galloste](https://forum.codewithmosh.com/u/galloste)\
**Replies:** 1\
**Last updated:** [October 6, 2021, 5:06pm UTC](https://forum.codewithmosh.com/t/entity-framework-6-and-sql-server-filestream/7775 "2021-10-06T17:06:50Z")

</div>

I’m trying to use entity framework with sql server filestream for big byte\[\] properties in my domain classes. At the moment to make it, I manually write custom scripts into the “Sql” void inside my migrations to create t…

---

## [Using the repository pattern with WPF](https://forum.codewithmosh.com/t/using-the-repository-pattern-with-wpf/7254)

<div class="topic-metadata">

**Author:** [@paolorugby](https://forum.codewithmosh.com/u/paolorugby)\
**Replies:** 0\
**Last updated:** [September 9, 2021, 11:55am UTC](https://forum.codewithmosh.com/t/using-the-repository-pattern-with-wpf/7254 "2021-09-09T11:55:19Z")

</div>

Hi, In the course, after learning how to implement the Reposotory pattern to structure my data access, the UnitOfWork is not used in the WPF example. Instead, Mosh uses the dbContext directly. Why? Is it not possible to…

---

## [ADO.NET Entity Data Model](https://forum.codewithmosh.com/t/ado-net-entity-data-model/2533)

<div class="topic-metadata">

**Author:** [@R0k0](https://forum.codewithmosh.com/u/R0k0)\
**Replies:** 2\
**Last updated:** [September 1, 2021, 5:32pm UTC](https://forum.codewithmosh.com/t/ado-net-entity-data-model/2533 "2021-09-01T17:32:08Z")

</div>

Hi, after installing package EntityFramework I don’t have “ADO.NET Entity Data Model” under new item. Installing NuGet package EntityFramework 6.4.4.

---

## [Understanding Entity migrations](https://forum.codewithmosh.com/t/understanding-entity-migrations/2949)

<div class="topic-metadata">

**Author:** [@ryan](https://forum.codewithmosh.com/u/ryan)\
**Replies:** 0\
**Last updated:** [February 23, 2021, 6:23pm UTC](https://forum.codewithmosh.com/t/understanding-entity-migrations/2949 "2021-02-23T18:23:32Z")

</div>

Taking the Angular x Dotnet Core course, and every time I want to start up the database, I run sudo docker run -e 'ACCEPT\_EULA=Y' -e 'SA\_PASSWORD=MyComplexPassword!234' -p 1433:1433 -d microsoft/mssql-server-linux and …
