ado.net-entity-data-model

Returning datatable using entity framework

六月ゝ 毕业季﹏ 提交于 2019-11-28 09:57:51
I am using entity framework. There is one particular situation in my application where I have to use a stored procedure. Since there are a lot of SQL statements written in the SP, I don't want to re-write it in my C# code. I only need to get the result back in the form of a datatable. I have written a little bit of code but I am stuck at one point. Can someone complete the code below? using (dbContext.Database.Connection) { dbContext.Database.Connection.Open(); DbCommand cmdItems= dbContext.Database.Connection.CreateCommand(); cmdItems.CommandText = "GetAvailableItems"; cmdItems.CommandType =

How to display a collection in View of ASP.NET MVC 4 Razor project?

戏子无情 提交于 2019-11-28 00:15:11
问题 I have the following Model: public class ContractPlain { public int Id { get; set; } public Guid ContractGuid { get; set; } public int SenderId { get; set; } public int RecvId { get; set; } public int ContractType { get; set; } public string ContractStatus { get; set; } public DateTime CreatedTime { get; set; } public DateTime CreditEnd { get; set; } } public class Contrtacts { List<ContractPlain> listOutput; public void Build(List<ContractPlain> listInput) { listOutput = new List

Entity Framework 4: Does it make sense to create a single diagram for all entities?

可紊 提交于 2019-11-27 17:24:31
I wrote a few assumptions regarding Entity Framework, then a few questions (so please correct where I am wrong). I am trying to use POCOs with EF 4. My assumptions: Only one data context can exist for an EF diagram. Data Contexts can refer to more than one entity. If you have two data sources, say MS SQL server and Oracle, EF requires two different diagrams to access the data. The EF diagram data context is the "Unit of Work", having a single Save() for anything on the diagram. (Sure you could wrap it in a UnitOfWork class, but it essentially has the same duties). Assuming that's correct, here

Entity framework: StoreGeneratedPattern=“Computed” property

做~自己de王妃 提交于 2019-11-27 14:43:37
I have a DateTime property. I need this property's default value to be DateTime.Now . And then I found out that you can specify an attribute StoreGeneratedPattern="Computed" and set it to (getdate()) in SQL. This works successfully. But I can't change this property in code. Sometimes I need to change this property to any DateTime value. But my changes are not saved. Adam Rackis Setting this property to Computed is telling EF that you cannot set the value directly. How could you? This property exists for the sake of computed columns, which by definition are not saved back to the database.

Metadata file not found - Data.Entity.Model

不问归期 提交于 2019-11-27 14:40:30
Anyone having similar problem, while creating webservices? Compiling transformation: Metadata file 'D:\Program Files\VS2013\Common7\Tools..\IDE\Microsoft.Data.Entity.Design.dll' could not be found D:\PROJEKTY\apki\ws2\WS\WS\DataModel.tt I tried adding data model again, restarting VS, cleaning and building solution, creating new project, deleting and adding reference, installing the newest version. I think that any solution found on internet does not work for me. Any suggestions? I think of pasting file into this directory, but can't think what may be there. Based on C:\Program Files (x86)

Missing “Ado.Net Entity Data Model” on Visual Studio 2013

守給你的承諾、 提交于 2019-11-27 13:30:35
I have created new web project but I can't find ADO.net Entity DAta Model to add it. How to fix it or Install it ? user3535560 Go to "C:\ProgramData\Package Cache" and search for "EFTools.msi". You should find two files, just install the most recent one (it should be about 960KB). This fixed the problem for me. i have the same problem, but there is no "EFTools.msi" in "C:\ProgramData\Package Cache" for me... UPDATE : i download and install "Entity Framework 6 Tools for Visual Studio 2012 & 2013" and it solved the problem \m/ Download Link Some web tutorials show a 'ADO.NET data entity model'

Columns of two related database tables in one ASP.NET GridView with EntityDataSource

喜欢而已 提交于 2019-11-27 13:12:50
I have two SQL Server tables with Primary Keys (PK) and a Foreign Key (FK) linking the two tables: 1) Table "Order" OrderID, int, PK AddressID, int, FK ... 2) Table "Address" AddressID, int, PK City, nvarchar(50) ... Then I've created an (ADO.NET) Entity Data Model out of those two tables. Now on my (ASP.NET) webpage I put a GridView with an EntityDataSource. In my GridView I want to display two columns: OrderID City (belonging to that order and linked by the AddressID-key) How can I do that? My problem is: When I configure the Entity Data Source I can select an "EntitySetName" which can be

Entity Framework: Setting a Foreign Key Property

情到浓时终转凉″ 提交于 2019-11-27 12:11:17
We have a table that looks roughly like this: CREATE TABLE Lockers { UserID int NOT NULL PRIMARY KEY (foreign key), LockerStyleID int (foreign key), NameplateID int (foreign key) } All of the keys relate to other tables, but because of the way the application is distributed, it's easier for us to pass along IDs as parameters. So we'd like to do this: Locker l = new Locker { UserID = userID, LockerStyleID = lockerStyleID, NameplateID = nameplateID }; entities.AddLocker(l); We could do it in LINQ-to-SQL, but not EF? Pieter Breed This missing feature seems to annoy a lot of people. Good news: MS

How to create “embedded” SQL 2008 database file if it doesn't exist?

戏子无情 提交于 2019-11-27 02:17:52
I've created a database application using C#, ADO.Net and an embedded MS SQL 2008 database file (that attaches to MS SQL 2008 Express) which I created in Server Management Studio. Can someone point me to a resource that describes how I can programmatically create the database file if it is missing (like right after my application is installed)? If it were me (when it is me...): You don't particularly want to be trying to make database files work by copying them and attaching them - there are reasons why you might want to but I believe these to be exceptions rather than rules. Accordingly what

Can't Create Entity Data Model - using MySql and EF6

邮差的信 提交于 2019-11-27 00:42:39
I'm trying to add an edmx Entity model to my C#/Web Project in Visual Studio 2013. My problem is that the file is not created. I do the following steps: Give the item a name Choose 'EF Designer from database' Choose the connection from the drop down (localhost) that already tested successfully connecting to MySQL databse The "Save connection settings in webc.config as" option is checked I click 'Next' AND the window disappeared and I get back to the code window No edmx file is created. (although it works with SQL Server, but not for MySQL) I have Entity Framework 6.1.2 installed, MySql.Data ,