background preloader

Entity Framework

Facebook Twitter

EntityFramework | Uli Armbruster. NuGet Packages auf neue NET Version aktualisieren Aktuell migrieren wir unsere Projekte / Solutions von .NET Framework 4.0 auf 4.5. Die Herausforderung bestand darin alle NuGet Packages, von denen wir viele verwenden, umzustellen. Ein Blick in die packages.config verrät, dass die installierten Pakete immer gegen eine entsprechende .NET Version gebunden sind: 1: <? Xml version="1.0" encoding="utf-8"?

2: <packages> 3: <package id="EntityFramework" version="5.0.0" targetFramework="net40" /> 4: </packages> Dies lässt sich auch in den zugehörigen Assemblies ablesen: Unter Path wird in diesem .NET 4.0 Projekt beispielsweise auf “packages\EntityFramework.5.0.0\lib\net40” verwiesen. Nach der Änderung des Target Frameworks auf 4.5, ergibt sich folgende Zeile in der packages.config: 1: <package id="EntityFramework" version="5.0.0" targetFramework="net40" requireReinstallation="True" /> Der requiresReinstallations-Schalter bewirkt Warnungen beim Build. Update-package -reinstall Beispiel 1: Testen der Query. Entity Framework conventions - Documentation. Code First includes a set of simple, model-wide behaviors that provide sensible configuration defaults for the parts of your model that have not been explicitly configured using Data Annotations or the Fluent API.

These default behaviors are referred to as Conventions. One commonly requested feature is the ability to add your own conventions. The Custom Conventions feature will let you define your own conventions to provide custom configuration defaults for your model. Ther are two main types of Conventions, Configuration Conventions and Model Conventions. Design Meeting Notes: Here are links to various design meeting notes where conventions discussions took place. Configuration Conventions Configuration Conventions are a way to configure a set of objects, without overriding the explicit configuration provided in the Fluent API. To start with we will show a commonly requested example. Convention Classes Model Conventions Convention Order.

Migration

Good to know. EF 5: Modelle übersichtlicher gestalten | Johnny's Blog. Startseite > .Net, dnugBern, webDotNet > EF 5: Modelle übersichtlicher gestalten EF 5: Modelle übersichtlicher gestalten Ob man nun “Model-First” oder “DB-First” folgt, bei Entity Framework steht man schnell einmal vor einem Problem: Das Datenmodell verliert an Übersichtlichkeit. Die oft verwendeten Beispiele mit wenigen Tabellen und Verbindungen sehen im Designer von Visual Studio prima aus. Hat man aber ein komplexeres Modell steht man bald einmal vor so einer Ansicht: Auch wenn man sehr viel Zeit aufwendet um die Entitäten hin und her zu ziehen, so bleibt das Modell doch unübersichtlich.

Verwendet man Entity Framework 5 und Visual Studio 2012 gibt es aber 2 Hilfsmittel die einem bei der Organisation helfen können. Farben Mit Hilfe von Farben kann man thematisch zusammenhängende Bereiche hervorheben. Die Farben haben einzig im Designer eine Bedeutung und beeinflussen das Modell nicht. Diagramme Für grosse Modelle sind die Farben zwar ein Anfang, doch ist man damit noch nicht am Ziel. Fazit. EF6 Alpha 3 Available on NuGet - ADO.NET Blog.

@Rowan Miller To answer your question regarding System.Data.Entity.Design, our scenario is the following: Environment: - 1800+ Tables - 20+ Schemas - 3200+ Foreign Keys (Cross Schema) (We can't use the designer due to sheer number of entities. Model Generation process: - Use EntityStoreSchemaGenerator to generate SSDL - Use EntityModelSchemaGenerator to generate CSDL - Generate Mappings (MSL) - Save EDMX in memory buffer. - Read Metadata for entire Database model from a separate database - Load the EDMX in a custom class model and rewrite it to achive the following: - Remove a set of excluded columns (exluded using Metadata) - Remove all undesired OneToMany relationships (based on Metadata; avoids having thousand of unwanted member collections in the generated code, IE all tables have foreign keys to the User table: remove all reverse relationships from user to all tables in the system as they are not needed and add a heavy performance tax when loading a related user) - Save modified EDMX.

Catalin Pop. Neuerungen im Entity Framework 5.0. Entity Framework Extended Batch Update and Future Queries - Paul Welter's Weblog. Entity Framework Extended Library A library the extends the functionality of Entity Framework. Features Batch Update and Delete Future Queries Audit Log Project Package and Source NuGet Package PM> Install-Package EntityFramework.Extended Batch Update and Delete A current limitations of the Entity Framework is that in order to update or delete an entity you have to first retrieve it into memory.

Deleting //delete all users where FirstName matches context.Users.Delete(u => u.FirstName == "firstname"); Update //update all tasks with status of 1 to status of 2 context.Tasks.Update( t => t.StatusId == 1, t => new Task {StatusId = 2}); //example of using an IQueryable as the filter for the update var users = context.Users .Where(u => u.FirstName == "firstname"); context.Users.Update( users, u => new User {FirstName = "newfirstname"}); Future Queries Future queries are created with the following extension methods... Future() FutureFirstOrDefault() FutureCount() Sample Audit Log Fluent Configuration. Data Points - Shrink EF Models with DDD Bounded Contexts.

When defining models for use with the Entity Framework (EF), developers often include all of the classes to be used throughout the entire application. This might be a result of creating a new Database First model in the EF Designer and selecting all available tables and views from the database. For those of you using Code First to define your model, it might mean creating DbSet properties in a single DbContext for all of your classes or even unknowingly including classes that are related to those you’ve targeted. When you’re working with a large model and a large application, there are numerous benefits to designing smaller, more-compact models that are targeted to specific application tasks, rather than having a single model for the entire solution. Domain-Driven Design and Bounded Context DDD is a fairly large topic that embraces a holistic view of software design.

DDD includes numerous software design patterns, one of which—Bounded Context—lends itself perfectly to working with EF.