ado.net-entity-data-model

Entity Framework Migrations Error - Sequence contains no elements

牧云@^-^@ 提交于 2019-12-09 07:39:56
问题 command: add-migration blahblah -verbose error: Sequence contains no elements I did a few things before getting this error. I made a change to my code-first model but did not run add-migration yet. Then I added an EDMX model to play around with an idea visually. I realized the EDMX model was messing with my code so I removed it. I tried to run add-migration and got "Sequence contains no elements". I upgraded to EF 5 and uninstalled the old Migrations package except for my configurations. Then

How to bind a query with a join to a DataGridView?

痴心易碎 提交于 2019-12-08 13:30:51
Right now, I have created a new Object data source based off from an Object Context from the entity model. I then created a BindingSource and a DataGridView set to this BindingSource. I can add columns which are bound to the data from the TraceLine table. When I set the DataSource, I see values in those columns. However, I can’t seem to get the data from the joined table. How do I bind a DataGridView to a query that has a join? using (var entities = new MyEntities()) { var lines = from t in entities.Lines join m in entities.Methods on t.MethodHash equals m.MethodHash where t

Can't add Ado .Net Entity Data Model

…衆ロ難τιáo~ 提交于 2019-12-08 12:45:50
问题 I'm doing these steps: Create new vs2010 C# console application Project menu -> Add New Item select Ado.NET Entity Data Model -> click Add Entity Data Model wizard window opened. Select Generate From database -> Click Next The next window appears for less than 1 second and it gets closed automatically. I tried to reset vs2010 setting but no good news, the problem still exist. I also tried it with ASP.NET Website. What is the problem? 回答1: I had a similar problem and finally fixed it by

unify two models (edmx) with visual studio 2010

孤人 提交于 2019-12-08 11:14:32
Hello as actually as i know you can not make relations between tow models or have in one models entities from two databases, it's a posibility two join two models both of them with existig databases behind? or there is some experience with a method like: move entities from the designer of one of them to the other and some bcp (SQL server) magic to move data and recreation on only one database? Thanks. As I know the answer is: No you can't join models targeting different databases and you can't place entities from multiple databases in single model. However you should be able to make relations

unify two models (edmx) with visual studio 2010

左心房为你撑大大i 提交于 2019-12-08 04:34:25
问题 Hello as actually as i know you can not make relations between tow models or have in one models entities from two databases, it's a posibility two join two models both of them with existig databases behind? or there is some experience with a method like: move entities from the designer of one of them to the other and some bcp (SQL server) magic to move data and recreation on only one database? Thanks. 回答1: As I know the answer is: No you can't join models targeting different databases and you

Property or indexer cannot be assigned to — it is read only [duplicate]

。_饼干妹妹 提交于 2019-12-08 04:07:20
问题 This question already has answers here : Closed 7 years ago . I'm capturing date of Birth and Date of Diagnosis in database and would like to calculate age in years by Diagnosis date. This is my code. But I have error following error. Error 2 Property or indexer 'LightSwitchApplication.Patient.AgeAtDiagnosis' cannot be assigned to -- it is read only partial void AgeAtDiagnosis_Compute(ref int result) { // Set result to the desired field value AgeAtDiagnosis = DateofDiagnosis.Year -

How do I pass a connection string to the constructor of a database-first DBContext with Entity Framework 4.1?

我怕爱的太早我们不能终老 提交于 2019-12-07 10:08:47
问题 For various reasons I would like to not store the connection string for my Entity Framework DB model in one of the various .config files. (I am using the latest and greatest DBContext API with the new Entity Framework version 4.1, .NET 4 and Visual Studio 2010 C#.) However, the code generation template for DBContext only creates a single parameterless constructor. (If I don't use the DBContext API, then my entity framework model has 7 different constructors to chose from, including the one I

ADO Entity Framework creating unwanted Entity Key

女生的网名这么多〃 提交于 2019-12-06 07:42:25
问题 I need to use tables from a DB which I cannot alter (using linked server). So part of my schema is a view on these table and I cannot create an FK in my DB. When I come to creating the association in ADO.NET Entity Framework I am getting problems because a second column on the table from the external DB has an index on it and the EF is creating an Entity Key for it (it's the name descr of the record - I think they just wanted to speed the ordering on it). When I take the Entity Key off this

Do we need DataContract attribute on POCO classes in Ado.net entity Framework 2010

妖精的绣舞 提交于 2019-12-05 06:07:54
问题 I read somewhere in stackoverflow itself that when we use POCO classes for WCF contracts using Poco generator , we need not use DataContract and DataMember attributes.WCF do it auto for you? . I don't know how it manages this. I created a sample application without using these attributes and I was able to generate those entities on client side and use them. I disabled proxy generation and Lazy loading. Am i missing anything here.? Is there really no need of putting these attributes. 回答1: You

How to create an Entity Data Model for inherited generic types?

荒凉一梦 提交于 2019-12-04 16:19:09
I have no clue how i can get an existing object structure based on the following classes (simplified) into a database using Entity Framework (EF is a constraint, i have to use it). public abstract class WahWahProperty { public string Name { get; set; } public abstract Type PropertyType { get; } } // ---------------- public class WahWahProperty<T> : WahWahProperty { public T Value { get; set; } public override Type PropertyType { get { return typeof(T); } } } // ---------------- public class WahWahContainer { public List<WahWahContainer> Children { get {...}; } public List<WahWahContainer>