entity-framework-4

Nullable database property but texbox still shows red border when content deleted

元气小坏坏 提交于 2019-12-05 18:35:52
Hi I am binding a WPF textbox to an Entity Framework property as follows: <TextBox Grid.Column="1" Grid.Row="0" Margin="5,2" Text="{Binding Path=MyEntityObject.SizeLower, Mode=TwoWay}" /> It binds fine to the property and when I change it, it saves to the DB as expected. But if I delete the content of the Textbox I get the red error border around it. I dont have any validator in place so I am guessing the texbox is complaining about the value not being nullable. But in fact this property in the DB is nullable, so I cannot understand why it would error. The system generated EF property

How do I represent an option calculated column with EF Code First?

纵饮孤独 提交于 2019-12-05 18:22:45
I have a situation where I have a table of entries that I'll be querying on, but in some cases I'll have additional information available. For instance, if I have a table of people , I want to be able to search by name, but I also want to store some coordinates and search based on their location, but also expose that distance in the object model. So, for instance, suppose my people table looks something like this: PersonId int Name nvarchar(100) Address nvarchar(100) Latitude float(10,6) Longitude float(10,6) And the entity class is defined like this: public class Person { public int PersonId

Entity Framework code first for Oracle

人走茶凉 提交于 2019-12-05 18:20:09
问题 Is there any possibility of using EF Code First for Oracle DB. Even though the DB generation is absent is there a way to the use the EF fluent API with Oracle DB. 回答1: Yes, actually we are using right now in a new project, but we had a lot of problems, some of them are not fixed yet. Take a look at this: Oracle ODP.Net and EF CodeFirst - edm.decimal error and this: Oracle ODP.Net and EF CodeFirst - SaveChanges Error 来源: https://stackoverflow.com/questions/9871879/entity-framework-code-first

Entity framework work locally but not on azure

北战南征 提交于 2019-12-05 18:06:15
I have a web project which works perfectly locally. But when I change the connection string in my published web site on Azure to connect to my database on SQL Azure it will start giving this error. System.Data.Entity.Infrastructure.UnintentionalCodeFirstException: Code generated using the T4 templates for Database First and Model First development may not work correctly if used in Code First mode. To continue using Database First or Model First ensure that the Entity Framework connection string is specified in the config file of executing application. To use these classes, that were generated

Table not mapped to Entity Framework Data Model

℡╲_俬逩灬. 提交于 2019-12-05 17:59:37
Hi I'm back with another question,I have started using EF and I'm having problem with it. OverView: I made an EF model ,and found out that one table (named UserRoles) didn't showed up in the EF Model Diagram ,I tried to add it through "Update data model" ,but wizard didn't showed me that table to add (as if it was already added) ,I also tried to refresh model through "Update data model" wizard it was not helpful. Problem Explained: The original DB Diagram. Partial EF Model Diagram I tried to add it through "Update data model" I tried to rename an entity in the EF diargram to "UserRoles",an

Entity Framework Code First CTP4 Default Column Values?

倾然丶 夕夏残阳落幕 提交于 2019-12-05 17:39:12
问题 I have been looking into Code First with Entity Framework CTP4 and you can use the ModelBuilder to build up your table columns. Is there a way to set the default value for a column in the database using the ModelBuilder or some other mechanism? Thank You! 回答1: Couldn't find a way to add default value other than manualy edit via text editor / application This is a bug in the Entity Framework... 回答2: I am using the constructor to set the default values. Never failed me public class Activity {

Why is the TableAttribute in the Entity Framework Dll?

只愿长相守 提交于 2019-12-05 17:15:34
Is there a good reason why the Table attribute (which can be used to map a POCO class to the correct database name/schema) is in the EntityFramework.dll? Doesn't this prevent you from creating a Domain project that simply contains your entities with no dependency on a specific data access technology? For example, if I use this attribute I don't believe the classes would be portable to Silverlight. Is this an oversight, or am I missing something? I realize I could use the fluent API to circumvent this, but the attribute seems preferable for this purpose. I think because the TableAttribute has

Is there an easy way to verify whether or not the database schema is exactly what I expect it to be using Entity Framework?

蹲街弑〆低调 提交于 2019-12-05 16:58:52
I want my application to verify database consitency at startup time. Is there an easy way to verify whether or not the database schema is exactly what I expect it to be using Entity Framework? EF4 itself does some verification. If a mapped type contains a column that does not exist in the target table, when EF4 is materializing it triggers an exception. Fine. However there are some things it does not do: It does not verify the entire database at first. It does not trigger an exception when the target table contains a column that is not mapped. Is there an easy way I can accomplish that? As to

Entity Framework 4.0: Entity SQL CAST Operation Not Working

痴心易碎 提交于 2019-12-05 16:32:10
I'm trying to make a query where I cast a text column, which contains an integer as text, to an Int32. Here's the query: SELECT VALUE t FROM MyEntities AS t WHERE CAST(t.TextColumn AS Edm.Int32) > 5 However, I get an System.Data.EntitySqlException with the following message: Type 'Edm.Int32' could not be found. Make sure that the required schemas are loaded and that the namespaces are imported correctly. Near type name, line 1, column 75. According to MSDN , Edm.Int32 should be a valid type. Does anyone know what's wrong? Edit: After some trial and error, I found that the following works:

Entity Framework Insert object with related object

和自甴很熟 提交于 2019-12-05 15:41:56
I am a newbie with Entity Framework and I need to insert an object Comment that has a related FK object User into the database. public Class Comment { public int CommentID { get; set; } public string CommentContent { get; set; } public virtual User User { get; set; } public virtual DateTime CommentCreationTime { get; set; } } public class User { public int UserID { get; set; } public string UserName { get; set; } public string UserPassword { get; set; } public string UserImageUrl{get; set;} public DateTime UserCreationDate { get; set; } public virtual List<Comment> Comments { get; set; } }