entity-framework-5

Windows Azure, Entity Framework. Keyword not supported: 'metadata'.

末鹿安然 提交于 2019-12-01 02:28:53
问题 This has been asked a few times but I haven't been able to make any of the suggestions work for me. I have a website and SQL database that I've build locally and now deployed into Azure. The database is a linked resource to the website. I am able to browse the website and I'm even able to connect and run queries against the database using ADO.Net and a standard connection string. The problem is when I try to connect using Entity Framework I keep getting Keyword not supported: 'metadata'. I've

Entity Framework DefaultConnectionFactory being ignored

雨燕双飞 提交于 2019-12-01 00:39:35
I'm using Entity Framework 5 with Code First. I've written a custom IDbConnectionFactory which I want to use for all the connections made by my DbContext class, so early on in the application's lifecycle, before any database work is done, I call Database.DefaultConnectionFactory = new MyConnectionFactory(); However, MyConnectionFactory.CreateConnection is never called, which suggests to me that EF's changed it back - but the debugger shows that it's still a MyConnectionFactory after several queries have run. For some reason, it's just not using it. My DbContext is initialised by passing the

How to do Migrations in DB first approach

为君一笑 提交于 2019-12-01 00:36:08
I am using entity framework DB first approach and wants to know how can i manage migrations in DB first approach. We're doing changes in database schema manually. Is there any way by which Entity Framework can apply the changes accordingly to the project. Harish Bhatt I guess I got confused between the code first with existing database and database first with model. What I understood is, after searching in different forums, Migrations are allowed only in code first approach. Code first assumes that you will never make any changes manually to the database. All the changes to the database will

Is there a way to make EF 5 code first migrations use a sql server database in ASP.NET MVC 4 for everything?

≯℡__Kan透↙ 提交于 2019-12-01 00:24:28
I would like for it to use SQL Server by default for everything when I start a new ASP.NET MVC 4 Web Application project. By default when you run this project it creates a LocalDb instance and creates the following tables in it: webpages_Membership webpages_OAuthMembership webpages_Roles webpages_UsersInRoles UserProfile I have been able to use a code first migration to put the UserProfile table into a SQL server database. However, I have not been able to accomplish this with the other 4 tables. Obviously my goal is to start with a single SQL Server database and have all of the tables for the

Can Entity Framework handle many to many relationship without an intersection object?

依然范特西╮ 提交于 2019-11-30 23:49:52
问题 Using database first model: Let's say we have the classic tables Student , Course and StudentCourse (the latter obviously having FKs to Student and Course ). If you import this model to EF, you will get an object generated for each of them. The Student and Course classes will each have a collection of StudentCourses , from which you need to jump another relationship to get to the Course or Student , respectively. I would like to have the code generated in such a way that the underlying

Entity Framework 5 - Looking for Central Point to Execute Custom Code after Entity is Loaded from Database

只谈情不闲聊 提交于 2019-11-30 23:34:03
问题 I am using Entity Framework 5 with Code First approach and using Fluent API for Entity configuration. My project has one particular Product Entity which gets half of its data from the database and the other half from a Data Contract retrieved via a WCF Client (its a 3rd party system used to manage product inventory). The Data Contract is a member of the Product Entity class (property or method I haven't decided yet). I prefer not to have any WCF Client logic contain within the Entities. I'd

Where is my database and how do I view it?

﹥>﹥吖頭↗ 提交于 2019-11-30 23:32:16
问题 I've just created a brand new application, added EntityFramework 5 via NuGet, created a very basic DbContext and saved some data to it. Where exactly is my data and how do I view it? The unmodified App.config it added is <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile

Entity Framework Poor COUNT Performance

人盡茶涼 提交于 2019-11-30 22:23:17
We are experiencing very poor performance using Entity Framework 5.0 with MySql Connector 6.6.6.0 for count based queries. Our data structure looks like: Table: Post =========== ID INT PRIMARY KEY MemberID INT NOT NULL SiteID INT NOT NULL Description VARCHAR(255) NOT NULL Image VARCHAR(255) NOT NULL CreatedDate DATETIME NULL And using entity framework with a linq query like the following: var count = entities.Post.Where(p => p.SiteID == 1 && p.CreatedDate != null).Count(); We get the following generated SQL: SELECT `Extent1`.`ID`, `Extent1`.`MemberID`, `Extent1`.`SiteID`, `Extent1`.

Entity Framework 5.0b2 Code First: One-To-Many and One-To-One for the same table, WITH Cascade Delete

喜欢而已 提交于 2019-11-30 21:51:35
After several hours of trial and error, I reached to this thread which explains how to establish a One-To-Many relationship and a One-To-One relationship with the same two types. However, I cannot get this to work with Cascade Delete: Thrown: "Unable to determine a valid ordering for dependent operations. Dependencies may exist due to foreign key constraints, model requirements, or store-generated values." (System.Data.UpdateException) Exception Message = "Unable to determine a valid ordering for dependent operations. Dependencies may exist due to foreign key constraints, model requirements,

How to do Migrations in DB first approach

戏子无情 提交于 2019-11-30 20:37:42
问题 I am using entity framework DB first approach and wants to know how can i manage migrations in DB first approach. We're doing changes in database schema manually. Is there any way by which Entity Framework can apply the changes accordingly to the project. 回答1: I guess I got confused between the code first with existing database and database first with model. What I understood is, after searching in different forums, Migrations are allowed only in code first approach. Code first assumes that