Entity framework code first caching - entity-framework

It is possible to use the Entity framework caching and tracing framework with the new entity framework 4.1 code first? If so then is there a good example of this, otherwise what is the best way to cache some queries?

Here is an example of a caching system for EntityFramework (with EDMX) http://code.msdn.microsoft.com/EFProviderWrappers-c0b88f32
Here is how you use that example with CodeFirst
http://jkowalski.com/2010/04/23/logging-sql-statements-in-entity-frameworkcode-first/
Although he is demoing the tracing provider rather than the caching provider you can use the same principals

Related

Creating a EF Core DbContext on a SAP Business One database

I am wondering about designing a EF core model of the SAP B1 database. I realize that this is a major undertaking, but I aim to start small.
This is mainly as an exercise, which may lead to something in the future.
My main issue right now, is to ensure that the DbContext is read-only.
I have found several suggestions, like this one:
How to make Entity Framework Data Context Readonly
However, that is for the Entity Framework "standard" not core, and the accepted solution does not seem to be possible with EF Core.
So, aside from using a login without write permissions, how would I go about making a read-only DbContext?
I am using EF Core 5.0.

Entity framework support in .net core 2.1

I have created a new application, using the SPA templare of .netcore, to this solution i want to add another project to handle the database connection(DAL).
When i am adding ASP.net core Web Application to this solution, i then want to add to id an ADO.net entityframework template, but in the data section, it dont appear:
So I end-up adding a class Library(.net framework)
and to it i can add an ADO.net Entity Data Model
So now in the solution, i have 2 projects, 1 is .net core 2.1 for the API's, models and views(by angular).
The second project is a .net framework 4.6.1, class library project.
My question is, is it suppose to be like that?
is it a good thing to mix different frameworks
Please see this article regarding what each framework is, and what each is specifically designed for.
https://learn.microsoft.com/en-us/dotnet/standard/frameworks
In a nutshell, your requirements drive which framework you choose.
I would recommend sticking with EF Core (just my personal opinion, take it or leave it) The EF Core method of database first is only recommended if you require a 1 time migration from a source database. Microsoft Doc
If you need to CONTINUE working with an entity model past the first migration, it would be in your best interest to use Entity Framework 6, on a .NET Framework library like you have. But that doesn't stop you from using EF Core as your OR/M, because you can indeed have .NET Core reference .NET Framework.

Deploy Entity Framework Core 2.0 alongside EF 6?

Is it possible to deploy / install Entity Framework Core 2.0 alongside traditional Entity Framework 6? Is it fully possible, or possible but with some hang-ups, or not possible? Is this documented somewhere? I think I've seen they said they designed it to be side-by-side, but I'm having a hard time fully confirming this. Thanks.
The official documentation says the following:
It is possible to use EF Core and EF6 in the same application. EF
Core and EF6 have the same type names that differ only by namespace,
so this may complicate code that attempts to use both EF Core and EF6
in the same code file.
If you are porting an existing application that has multiple EF
models, then you can selectively port some of them to EF Core, and
continue using EF6 for the others.
This means of course that you can install both EF6 and EF Core in the same project. I have done this in a few simple cases myself and it was working ok.

Breeze.Net Connecting to Entity Framework

Okay going to try to keep the fluff to a minimum. First we are new to Breeze. We have a project where the "Database First" Entity Framework was created. Using the SPA approach for offline webpage with AngularJS/BreezeJS combination. Angular seems to be working fine and as stated the Entity Framework EDMX file already exists.
Can I connect Breeze.Net to our Entity Framework and if so are there any examples of this specifically the Server side connection part? But the full example would be best. aka Entity Framework to Breeze.Net to BreezeJS
If I cannot connect Breeze to my Entity Framework, can I do a "Database First" Breeze.Net approach and if yes is there an example of how to do this?
Thanks in advance.
Breeze documentation includes many pertinent samples including the most basic Angular Todo sample. Among the samples, "DocCode" has the most sophisticated .NET Web API / EF variations (you can mentally translate from Knockout to Angular for the front-end).
You can download or clone them all from github.
Most (if not all) EF samples rely on a code-first model but you should have no trouble with a DbContext generated "DB First" (or with an old-school ObjectContext).

How can I use MVC4 Migrations without using Entity Frameworks?

How can I use MVC4 Migrations without using Entity Frameworks? I would really like to use data migrations but I am not using Entity Frameworks. I am using dapper-dot-net.
Yes, you can use Migrations without using Entity Framework. All Migrations cares about is the metadata it uses to manage the database and you need to use some EF stuff to handle that, but you then don't ever need to use EF to actually access the database. This blog post describes the process in detail: http://weblogs.asp.net/fredriknormen/archive/2012/02/15/using-entity-framework-4-3-database-migration-for-any-project.aspx
Check out Insight.Database.Schema on NuGet. It gives you a lot of the magic of migrations without the hassle of EF. I'll be updating the docs on github over the next few days.