entity-framework-4

How to get Entity Framework 4.2 without Nuget?

爷,独闯天下 提交于 2019-12-06 19:42:20
问题 We need to get hold of Entity Framework 4.2 to test out the SQL generation in 4.2. Unfortunately, our development environment does not allow us to use Nuget. Is there any way to get EF4.2 binaries so that we can test it out? 回答1: Could you use something like the NuGet Package Explorer (not a part of NuGet)? http://npe.codeplex.com/ Or, you may be able to download it directly: http://packages.nuget.org/v1/package/download/entityframework/4.2.0.0 回答2: If your development environement doesn't

ASP.NET MVC & EF4 Entity Framework - Are there any performance concerns in using the entities vs retrieving only the fields i need?

穿精又带淫゛_ 提交于 2019-12-06 16:46:10
问题 Lets say we have 3 tables, Users, Products, Purchases. There is a view that needs to display the purchases made by a user. I could lookup the data required by doing: from p in DBSet<Purchases>.Include("User").Include("Product") select p; However, I am concern that this may have a performance impact because it will retrieve the full objects. Alternatively, I could select only the fields i need: from p in DBSet<Purchases>.Include("User").Include("Product") select new SimplePurchaseInfo() {

Unique constraint in Entity Framework [duplicate]

我与影子孤独终老i 提交于 2019-12-06 16:44:43
问题 This question already has answers here : Unique keys in Entity Framework 4 (5 answers) Closed 6 years ago . How can one set some attribute in Entity (Entity Framework) to be unique? One possibility would be to make it primary key but that's not what I want. 回答1: Entity framework doesn't support unique keys so the only way is to set the unique constraint / index in the database. It will not ensure uniqueness in the application when you try to insert / update records but the exception will be

What causes POCO proxy entities to only sometimes be created in Entity Framework 4

偶尔善良 提交于 2019-12-06 16:44:13
I have set up my POCOs and I have marked their public properties as virtual and I am successfully getting Proxies most of the time (95%) but randomly I am getting EF return some proxies and some non-proxies. Recycling the app pool when this happens will then fix this instance of the error and it will go away for an amount of time. Then it will re-occur in some other random (it seems) place. What can cause this sort of behaviour? alt text http://www.freeimagehosting.net/uploads/36c95af3c7.jpg Thanks, Kohan Solved it (im getting in the habit of almost giving up, posting here and then solving it)

mvc-mini-profiler configuration clarification

喜欢而已 提交于 2019-12-06 16:09:10
问题 The profiler is installed in my MVC 3 app and it works, but what I'm having a hard time with is the correct way to get the EF 4 db portion setup correctly. from the home page of the profiler Use a factory to return your connection: public static DbConnection GetOpenConnection() { var cnn = CreateRealConnection(); // wrap the connection with a profiling connection that tracks timings return MvcMiniProfiler.Data.ProfiledDbConnection.Get(cnn, MiniProfiler.Current); } Entity Framework public

multiple “1 to 0..1” relationship models

孤人 提交于 2019-12-06 15:05:02
I am using this tutorial from microsoft to create a one-zero-to-one relationship with EF4.1 Between an Instructor and OfficeAssignment. This is working like a charm. But now I want to add a Home for each Instructor (1 to zero-or-1) like in this: I added the Home model exactly the same way as the OfficeAssignment (like in the tutorial above), but when I try to add controllers for these model, I get the error "An item with the same name has already been added". So my model is set up incorrectly. What is wrong with the below? How do I create multiple one-to-zero-to-one relationships in EF4.1?

Why the order of params of function imported from stored procedure changed?

一笑奈何 提交于 2019-12-06 14:22:32
I have a stored procedure in SQL Sever 2008 like: ALTER PROCEDURE [dbo].[mySP] @FirstName As varchar(30), @LastName As varchar(30), @ID As int As Begin --...... End then in EF imported this SP as a function like: public ObjectResult<Nullable<global::System.Int32>> MyFunc(global::System.String LastName, global::System.String FirstName,Nullable<global::System.Int32> ID) { //.... } it works fine for long time. Then I add some new thing to EF edmx with "update from database" today, the function parameter changed! it became: public ObjectResult<Nullable<global::System.Int32>> MyFunc(global::System

Get Last ID From The table [ Entity Framework ]

99封情书 提交于 2019-12-06 14:12:58
问题 Could someone guide me on this. I am using EntityFramwork4 , I want to get the ID of the last row of a table. Could someone having experience using this tell me , how can i get the last id from a database table. 回答1: Relational databases have no intrinsic order. There is no such thing as "the last row." Even if there were, multiuser concurrency would make this meaningless. Max(id) probably doesn't solve your issue due to concurrency. But since you haven't told us what the real problem you're

Setting up .NET MVC3 with MySQL

蓝咒 提交于 2019-12-06 13:57:05
Hy Guys, How can I configure the webconfig to access a mysql db using MVC 3? To use SQLExpress I included this code to configure in an example... <add name="MovieDBContext" connectionString="Server=.\SQLEXPRESS; Database=Movies;Trusted_Connection=true" providerName="System.Data.SqlClient" /> I'm using Entity Framework. PS.: I don't want to automatically create tables with the MVC. I want to create them manually. Thks! Austin M Take a look at this post, it seems like your best option is to use MySql Connector with EF Using MySQL with Entity Framework your connection string should look something

Error when running Update-Database with EF 4.3

倾然丶 夕夏残阳落幕 提交于 2019-12-06 13:56:15
I upgraded a project to Entity Framework 4.3 and enabled migrations on the project. However, I get this error when running the Update-Database command: Cannot scaffold the next migration because the target database was created with a version of Code First earlier than EF 4.3 and does not contain the migrations history table. To start using migrations against this database, ensure the current model is compatible with the target database and execute the migrations Update process. (In Visual Studio you can use the Update-Database command from Package Manager Console to execute the migrations