ado.net-entity-data-model

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

末鹿安然 提交于 2019-12-17 15:18:46
问题 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

Entity Framework: Setting a Foreign Key Property

大憨熊 提交于 2019-12-17 10:37:26
问题 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

Using Entity Data Model in VS 2012

[亡魂溺海] 提交于 2019-12-13 00:40:50
问题 I have used Entity Data Model before with VS 2010, but now I am having trouble with VS 2012. First of all, now in 2012 Entity Data Model there are two new files with .tt extension. Also the Designer.cs file is empty and has a message how to enable the code generation, but when I do enable the code generation it says that the objects already exist. I am also missing the CreateObjectSet(); using (MyEntities entitiesContext = new MyEntities()) { var entitySet = entitiesContext.CreateObjectSet<T>

MSDTC issue with transactions in ADO.NET Entity Framework

我们两清 提交于 2019-12-12 10:47:55
问题 in our current project we are using ADO.NET Entity Framework as data layer for the application. There are some tasks which require to run in a transaction because there's a lot of work to do in the database. I am using a TransactionScope to surround those tasks. using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew)) { // Do something... transactionScope.Complete(); } The problem is as soon as i am using an TransactionScope an exception occurs:

this operation is not supported in the WCF test client(WCF + ENTITY DATA MODEL)

微笑、不失礼 提交于 2019-12-12 05:18:32
问题 I am getting the error this operation is not supported in the wcf test client because it uses type catNameService.catNames[] Class and IClass code: catService class: namespace catNameService { class catService:IcatService { public IEnumerable<catNames> sortBySex(int genderNumber) { using (var context = new catNamingEntities()) { return context.catNames.Where(t => t.Gender == genderNumber).ToList(); } } } } IcatService interface: namespace catNameService { [ServiceContract] public interface

List<Tuple<T1,T2,T3>> to Database Mapping

有些话、适合烂在心里 提交于 2019-12-12 05:06:01
问题 I have a class defined as below public class blog { public int Id { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } // a list of author's info including author's id, name, department public List<Tuple<int, string, string>> Authors { get; set; } } I don't know if any exist ORM solution can do this List<Tuple<int, string, string>> to database mapping for me? I use massive a lot and trying to use NHibernate & EF 4.3 to solve this problem, however, nothing

EntityConnection error The specified named connection is either not found in the configuration

送分小仙女□ 提交于 2019-12-12 02:25:39
问题 Well, I know there was some topic about that, but believe me - i tried everything and still didn't get answer how to solve that issue. Error: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid. In app.config i have connection string: <add name="GetProductsEntities" connectionString="metadata=res://*/GetProductsModel.csdl|res://*/GetProductsModel.ssdl|res://*/GetProductsModel.msl;provider=System.Data

Databind ADO.NET Entity Framework to ListBox

…衆ロ難τιáo~ 提交于 2019-12-11 06:34:17
问题 I'm trying to attach a ADO EF object class (Materials) to a ListBox, and have it auto-update when a new material is added to the database. In my current code below, it will show any items that are in the database before the controls datasource is set, but it will not update. I know I'm missing something elementary here. Any help is greatly appreciated! public partial class Main : KryptonForm { private AGAEntities db = new AGAEntities(); public Main() { InitializeComponent(); } private void

Entity Sql for a Many to Many relationship

半腔热情 提交于 2019-12-11 01:25:14
问题 Consider two tables Bill and Product with a many to many relationship. How do you get all the bills for a particular product using Entity Sql? 回答1: You need to use some linq like this; ... using (YourEntities ye = new YourEntities()) { Product myProduct = ye.Product.First(p => p.ProductId = idParameter); var bills = myProduct.Bill.Load(); } ... This assumes that you have used the entitiy framework to build a model for you data. The bills variable will hold a collection of Bill objects that

What is the meaning of the “Pluralize or singularize generated object names” setting?

假装没事ソ 提交于 2019-12-09 14:20:21
问题 When setting up a new Entity data Model, there is an option to [x] Pluralize or singularize generated object names I have noticed this is an option in LINQ as well. Also, now that I am studying the ADO.NET entity framework, I noticed it also has 'DEFAULT' to 'pluralize or singularize generated object names' What is the result of not checking/allowing this option when setting up the 'Entity Data Model'. What Advantages/Disadvantages/issues will I face by making a selection one way or the other