In my database there's a datetime column "Created" with default value getutcdate(). I would like my EF datacontext to generate an insert query that doesn't set this column, and fetch the resulting value. Is there a way to do this?
I tried setting StoreGeneratedPattern to either None, Identity or Computed, I get an exception that DateTim...
Is it possible to define DateTime properties in entity objects that are of Kind == DateTimeKind.Utc by using either the .edmx file, or a t4 template?
When possible using t4, please describe how to change the property. Currently the property gets generated as:
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
[Dat...
Hello
I have this:
[Range(1, 1000, ErrorMessage = "Enter a value between 1 and 1000")]
public object ObjectLimit { get; set; }
Works great, but it doesnt show the error message, it shows some standard "The value '554g' is not valid for the ObjectLimit field."
How do I fix that?
...
When calling context.SaveChange(), I get an exception: {"An error occurred while updating the entries. See the InnerException for details."} with an InnerException of "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."
Generally this error is pretty easy to fix -- just find the DateTime property whos...
We're working in EFv1 and I'm implementing a search control with several filter options. Most of them I translate into .Where clauses and that is ok with EF.
But there is one specific filter that can make my application run very slow: text search. The column in the database has a corresponding entity property in my EF model, but I just ...
I have created POCO domain objects that map to the entities in the entity domain model.
Everything was working fine until now when I have to work with the many-to-many relationship.
Let's say I have three tables.
- Blog
- BlogTag
- Tag
You can see that Blogs and Tags are many-to-many with a bridge table, BlogTag that cont...
I'm using the Microsoft.Data.Entity.CTP (in the Entity Framework CTP) under the .NET 4 framework to create the EDMX metadata from my C# classes to create a database schema.
I setup a simple model as such:
public class AModelContainer : ObjectContext
{
public IObjectSet<RegularClass> RegularClasses {
get { return CreateObje...
We would like to publish a base model, that represents our core business data.
Separate departments would reference this base model, (published as an .NET assembly)
Their project would create their schemas that reference the core business schema.
Is it possible that each team would reference this common assembly, and then build their o...
I have a table w/ a sql date data type. When I look at the EDM markup, the storage element reflects this. The conceptual entity has a data type of DateTime (there doesn't appear to be a Date data type). When I call save changes and have a DateTime instance associated w/ the entity I want to persist, I get the following error:
The conver...
I'm trying to figure out how to share my entities between the data, business, and UI tiers. Is it best to create a separate project for these entities that will be referenced by all the tiers? What about Enums and custom exceptions? I have some enums used only by the UI project, and some that are used by the Business. Does this mean ...
I am creating the Entity Framework ObjectContext per ASP.NET Request using the following code:
public static class ObjectContextPerRequest
{
public static EStudyTestDatabaseEntities Context
{
get
{
var _context = HttpContext.Current.Items["EStudyModel"] as EStudyTestDatabaseE...
Hi everyone,
We've used the Validation Block of MS Enterprise Library for some time with great success in conjunction with custom DALs but we've recently started using the Entity Framework and can't get the Validation Block to work with it. The objects are dynamically created in EF and putting attributes on top of them will simply get ...
This works in LINQ-to-SQL:
var customersTest = from c in db.Customers
select new
{
Id = c.Id,
Addresses = from a in db.Addresses where c.Id.ToString() ==
a.ReferenzId select a
};
foreach (var item in customersTest)
{
Con...
Is there a way to use EF without transaction? I have very simple single insert and don't want to roll-back when something goes wrong as there may be a trigger logging then raising error from the DB side which I have no control over. I just want to insert then catch any exceptions but don't want to roll-back.
...
Hi,
Iam working on sorting the grid remotely.
Iam using the folllowing query
SELECT value a, ROW_NUMBER() OVER (ORDER BY" + " " + SortExpression + ") As RowNumber FROM XSP_AssetList_V AS a WHERE a.AccountID = GUID'" + AccountID + "'";
is there any linq equivalanet for rownumber() over orderby()
but iam getting an error
System.Dat...
Ok this one is might not have a straight forward answer but lets see.
I am trying to design a DAL that will sit on the network and serve EF objects to developers who are writing clients that need to use our database.
For example:
The DAL has some EF objects called PERSON and DEPARTMENT.
A developer wants to write a client that can ...
Hi,
The re-design for a large database at our company makes extensive use of composite primary keys on the database.
Forgetting performance impacts, will this cause any difficulties when working with this db in Entity Framework 4.0? The database structure is unlikely to change and I'm not looking for "philosophical" debate but what are...
I am looking into migrate a large project to Entity Framework 4.0 but am not sure if it can handle my inheritance scenario.
I have several projects that inherit from an object in the “main” project. Here is a sample base class:
namespace People
{
public class Person
{
public int age { get; set; }
public String...
Hello,
I'm using EF v1. I have following tables:
CREATE TABLE category (
category_id int ,
category_name varchar(100) not null,
CONSTRAINT PRIMARY KEY (category_id)
)
CREATE TABLE categoryDetails (
detail_id int,
category_desc varchar(100) not null,
category_id int NOT NULL,
CONSTRAINT PRIMARY KEY (detai...
I was debugging Jaroslaw Kowalski provider wrappers. While debugging it I observed that the Entity Framework closes the connection after every query. On every interaction with database, during the lifetime of application, a database connection is opened and after performing the query the connection is closed
My questions are:
-Whether t...