Quantcast
Channel: Entity Framework
Viewing all 10318 articles
Browse latest View live

New Post: EF6 code First - Map key to struct with implicit conversion

$
0
0
Hello,

I have a similar problem with Key and ForeignKey. I m trying to apply DDD principle but i m working on database with auto generated sequence. Has I want to always have a unique key without getting next value in sequence at entity creation.
I have a create my own Identity Object :
public class Identity<TIdentity> where TIdentity : struct 
{
    public TIdentity BaseIdentity { get; protected set; }

    private Guid AutoGeneratedIdentity { get; set; }

    protected Identity()
    {
    }

    public Identity(TIdentity identite)
    {
        this.BaseIdentity = identite;
    }

    public Identity(Guid guid)
    {
        this.AutoGeneratedIdentity = guid;
        DomainEvents.Register<IdentityChangedEvent<TIdentity>>(this.IdentityChanged);
    }

    private void IdentityChanged(IdentityChangedEvent<TIdentity> changedEvent)
    {
        if(!this.BaseIdentity.Equals(default(TIdentity))) return;

        if (this.Equals(changedEvent.Identity))
        {
            this.BaseIdentity = changedEvent.Identity.BaseIdentity;
        }
    }

    public void DefinirLidente(TIdentity identite)
    {
        BaseIdentity = identite;
        DomainEvents.Raise(new IdentityChangedEvent<TIdentity>(this));
    }

    public static Identity<TIdentity> CreeUneIdentity()
    {
        return new Identity<TIdentity>(Guid.NewGuid());
    }

    public override bool Equals(object obj)
    {
        var identity = obj as Identity<TIdentity>;
        return this.Equals(identity);
    }

    public bool Equals(Identity<TIdentity> identity)
    {
        if (identity == null)
        {
            return false;
        }

        if (this.BaseIdentity.Equals(default(TIdentity)) || identity.BaseIdentity.Equals(default(TIdentity)))
        {
            return this.AutoGeneratedIdentity.Equals(identity.AutoGeneratedIdentity);
        }

        return this.BaseIdentity.Equals(identity.BaseIdentity);

    }

    public override int GetHashCode()
    {
        return this.BaseIdentity.Equals(default(TIdentity)) ? this.AutoGeneratedIdentity.GetHashCode() : this.BaseIdentity.GetHashCode();
    }

    public override string ToString()
    {
        return string.Format("Identite : {0}",
            this.BaseIdentity.Equals(default(TIdentity))
                ? this.AutoGeneratedIdentity.ToString()
                : this.BaseIdentity.ToString());
    }

    public static implicit operator TIdentity(Identity<TIdentity> identity)
    {
        return identity.BaseIdentity;
    }

    public static implicit operator Identity<TIdentity>(TIdentity identity)
    {
        return new Identity<TIdentity>(identity);
    }
}


But as I can't affect Key or Foreign Key to this object, I need to had this property foreach Key or Foreign Key and it s working but would be cleaner if I didn't need it.
    public decimal BaseId
    {
        get { return this.Id.BaseIdentity; }
        protected set
        {

            if(!value.Equals(this.Id.BaseIdentity))
                this.Id = value;
        }
    }

Created Unassigned: Release 6.1.1 should be made current [2559]

$
0
0
Instead of being planned: https://entityframework.codeplex.com/releases/view/118657

Commented Feature: "SELECT" Stored Procedures in EF (not only for I/U/D) [1772]

$
0
0
...what I mean with SELECT Stored Procedures was to select a SP and the Designer should build the Entity from the result of that SP - all of our Data access goes through Stored Procedures for Select/Insert/Update/Delete and the SELECT result doesn't often map to tables because we return special columns from multiple tables...
Comments: Hey Robert, The workaround for lack of native support is to issue a raw sql query against the SPROC. You can do this and still get full change tracking support, identity resolution, etc. http://msdn.microsoft.com/en-us/data/jj592907. Mapping an entity set directly to a stored procedure is perhaps not the best thing because you typically use LINQ to retrieve data and composing a query on top of a SPROC isn't ideal. We have the concept of FunctionImports, which support the idea of calling a function with parameters (which maps to a stored procedure). Given all this (less common scenario, and possible to do - just not super pretty), I don't think it's something were going to add better support to the core framework for in the immediate future. ~Rowan

Commented Issue: Absent join for one of the second-level linked entities [2548]

$
0
0
If an entity has 2 properties that reference to the same first-level entity (but different records) and this first-level entity has reference to some second-level entity, EF 6.1.2-beta1 generates query with only one join for second-level entity.

For example, I have this model:
```
public class Main
{
public int Id { get; set; }
public string Value { get; set; }

public int Link1Id { get; set; }
public Link Link1 { get; set; }

public int Link2Id { get; set; }
public Link Link2 { get; set; }
}

public class Link
{
public int Id { get; set; }
public string Value { get; set; }

public int SublinkId { get; set; }
public SubLink Sublink { get; set; }
}

public class SubLink
{
public int Id { get; set; }
public string Value { get; set; }
}
```

When I try to query all Main entities with Link And SubLink, EF 6.1.1 generstes:
```
SELECT
[Extent1].[Id] AS [Id],
[Extent1].[Value] AS [Value],
[Extent1].[Link1Id] AS [Link1Id],
[Extent1].[Link2Id] AS [Link2Id],
[Extent2].[Id] AS [Id1],
[Extent2].[Value] AS [Value1],
[Extent2].[SublinkId] AS [SublinkId],
[Extent3].[Id] AS [Id2],
[Extent3].[Value] AS [Value2],
[Extent4].[Id] AS [Id3],
[Extent4].[Value] AS [Value3],
[Extent4].[SublinkId] AS [SublinkId1],
[Extent5].[Id] AS [Id4],
[Extent5].[Value] AS [Value4]
FROM [dbo].[Mains] AS [Extent1]
INNER JOIN [dbo].[Links] AS [Extent2] ON [Extent1].[Link1Id] = [Extent2].[Id]
INNER JOIN [dbo].[SubLinks] AS [Extent3] ON [Extent2].[SublinkId] = [Extent3].[Id]
INNER JOIN [dbo].[Links] AS [Extent4] ON [Extent1].[Link2Id] = [Extent4].[Id]
INNER JOIN [dbo].[SubLinks] AS [Extent5] ON [Extent4].[SublinkId] = [Extent5].[Id]
```

The same query for EF 6.1.2-beta1 is:
```
SELECT
[Extent1].[Id] AS [Id],
[Extent1].[Value] AS [Value],
[Extent1].[Link1Id] AS [Link1Id],
[Extent1].[Link2Id] AS [Link2Id],
[Extent2].[Id] AS [Id1],
[Extent2].[Value] AS [Value1],
[Extent2].[SublinkId] AS [SublinkId],
[Extent3].[Id] AS [Id2],
[Extent3].[Value] AS [Value2],
[Extent4].[Id] AS [Id3],
[Extent4].[Value] AS [Value3],
[Extent4].[SublinkId] AS [SublinkId1]
FROM [dbo].[Mains] AS [Extent1]
INNER JOIN [dbo].[Links] AS [Extent2] ON [Extent1].[Link1Id] = [Extent2].[Id]
INNER JOIN [dbo].[SubLinks] AS [Extent3] ON [Extent2].[SublinkId] = [Extent3].[Id]
INNER JOIN [dbo].[Links] AS [Extent4] ON [Extent1].[Link2Id] = [Extent4].[Id]
```

As a result both SubLinks has the same value equals to SubLink of Link1.

Sample is attached.
Comments: At first glance this seems to happen because PropertyOp does not override IsEquivalent to compare the associated PropertyInfo. If my assumption is correct, it should be an easy fix.

Commented Feature: "SELECT" Stored Procedures in EF (not only for I/U/D) [1772]

$
0
0
...what I mean with SELECT Stored Procedures was to select a SP and the Designer should build the Entity from the result of that SP - all of our Data access goes through Stored Procedures for Select/Insert/Update/Delete and the SELECT result doesn't often map to tables because we return special columns from multiple tables...
Comments: Hello Rowan, Thanks for your Response - I wondering that there are so few People who are using Stored procedures also for retrieving data - we use SP's because we have many complex SQL queries and to do this with LINQ is not possible/complicated... it is very interesting that such a functionality (use Stored Procedures for all also select) was there for ADO.NET Typed Datasets with Table Adapters but I think it is not useful/possible to use Table Adapters in new Projects (ASP.NET MVC)? Maybe the best is to use native ADO.NET or the Enterprise Library Data Access Application Block to call the stored procedures? robert

Reviewed: EF 6.1.0 (十月 18, 2014)

$
0
0
Rated 5 Stars (out of 5) - 为啥非要留言才能下载?

Created Unassigned: Very slow query plan building/outofmemory exception [2560]

$
0
0
Giving the following model:

```
public class BugContext : DbContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);

modelBuilder.Entity<Class1>().HasRequired(c => c.Relation).WithRequiredDependent().WillCascadeOnDelete(false);
modelBuilder.Entity<Class1>().HasRequired(c => c.Relation1).WithRequiredDependent().WillCascadeOnDelete(false);
modelBuilder.Entity<Class1>().HasRequired(c => c.Relation2).WithRequiredDependent().WillCascadeOnDelete(false);
modelBuilder.Entity<Class1>().HasRequired(c => c.Relation3).WithRequiredDependent().WillCascadeOnDelete(false);
modelBuilder.Entity<Class1>().HasRequired(c => c.Relation4).WithRequiredDependent().WillCascadeOnDelete(false);
modelBuilder.Entity<Class1>().HasRequired(c => c.Relation5).WithRequiredDependent().WillCascadeOnDelete(false);
}

public DbSet<Class1> Class1s { get; set; }
}

public class Class1
{
public int Id { get; set; }
public virtual Class2 Relation { get; set; }
public virtual Class2 Relation1 { get; set; }
public virtual Class2 Relation2 { get; set; }
public virtual Class2 Relation3 { get; set; }
public virtual Class2 Relation4 { get; set; }
public virtual Class2 Relation5 { get; set; }
}

public class Class2
{
public int Id { get; set; }

public string Code { get; set; }
}
```

And the following test code
```
using (var context = new BugContext())
{
var query2 = from c in context.Class1s.OrderBy(c => c.Id).Take(100)
let rel = c.Relation
let rel1 = c.Relation1
let rel2 = c.Relation2
let rel3 = c.Relation3
let rel4 = c.Relation4
let rel5 = c.Relation5
select new
{
c.Id,
Relation = new
{
rel.Id,
rel.Code,
},
Relation1 = new
{
rel1.Id,
rel1.Code,
}
};

var sw = Stopwatch.StartNew();
var sql = query2.ToString();
sw.Stop();
Console.WriteLine(sw.Elapsed);
}
```

Produces an out-of-memory exception.
Removing the "let rel5 = c.Relation5" lets the ToString() finish in around 18 secs.
Removing the "let rel4 = c.Relation4" as well brings this down to 2 secs.

As you can see, the relations don't have to be used in the actual projection but using them gives the same results.
This is the smallest version I could build to reproduce the error, the original error came from an EF6 edmx using ObjectContext.

Removing the ".OrderBy(c => c.Id).Take(100)" will let it complete in 100ms.

Commented Unassigned: Very slow query plan building/outofmemory exception [2560]

$
0
0
Giving the following model:

```
public class BugContext : DbContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);

modelBuilder.Entity<Class1>().HasRequired(c => c.Relation).WithRequiredDependent().WillCascadeOnDelete(false);
modelBuilder.Entity<Class1>().HasRequired(c => c.Relation1).WithRequiredDependent().WillCascadeOnDelete(false);
modelBuilder.Entity<Class1>().HasRequired(c => c.Relation2).WithRequiredDependent().WillCascadeOnDelete(false);
modelBuilder.Entity<Class1>().HasRequired(c => c.Relation3).WithRequiredDependent().WillCascadeOnDelete(false);
modelBuilder.Entity<Class1>().HasRequired(c => c.Relation4).WithRequiredDependent().WillCascadeOnDelete(false);
modelBuilder.Entity<Class1>().HasRequired(c => c.Relation5).WithRequiredDependent().WillCascadeOnDelete(false);
}

public DbSet<Class1> Class1s { get; set; }
}

public class Class1
{
public int Id { get; set; }
public virtual Class2 Relation { get; set; }
public virtual Class2 Relation1 { get; set; }
public virtual Class2 Relation2 { get; set; }
public virtual Class2 Relation3 { get; set; }
public virtual Class2 Relation4 { get; set; }
public virtual Class2 Relation5 { get; set; }
}

public class Class2
{
public int Id { get; set; }

public string Code { get; set; }
}
```

And the following test code
```
using (var context = new BugContext())
{
var query2 = from c in context.Class1s.OrderBy(c => c.Id).Take(100)
let rel = c.Relation
let rel1 = c.Relation1
let rel2 = c.Relation2
let rel3 = c.Relation3
let rel4 = c.Relation4
let rel5 = c.Relation5
select new
{
c.Id,
Relation = new
{
rel.Id,
rel.Code,
},
Relation1 = new
{
rel1.Id,
rel1.Code,
}
};

var sw = Stopwatch.StartNew();
var sql = query2.ToString();
sw.Stop();
Console.WriteLine(sw.Elapsed);
}
```

Produces an out-of-memory exception.
Removing the "let rel5 = c.Relation5" lets the ToString() finish in around 18 secs.
Removing the "let rel4 = c.Relation4" as well brings this down to 2 secs.

As you can see, the relations don't have to be used in the actual projection but using them gives the same results.
This is the smallest version I could build to reproduce the error, the original error came from an EF6 edmx using ObjectContext.

Removing the ".OrderBy(c => c.Id).Take(100)" will let it complete in 100ms.
Comments: Seems the DbContext is actually behaving differently then ObjectContext. The generated SQL contains a total of 210 joins on Class2 when putting let rel4 and let rel5 in comment. So the following 2 queries produce very different results. ``` var query = (from c in context.Class1s let rel = c.Relation let rel1 = c.Relation1 let rel2 = c.Relation2 let rel3 = c.Relation3 //let rel4 = c.Relation4 //let rel5 = c.Relation5 select new { c.Id, Relation = new { rel.Id, rel.Code, }, Relation1 = new { rel1.Id, rel1.Code, } }).OrderBy(c => c.Id).Take(100); ``` The SQL contains a total of 9 joins on Class2. ``` var query2 = from c in context.Class1s.OrderBy(c => c.Id).Take(100) let rel = c.Relation let rel1 = c.Relation1 let rel2 = c.Relation2 let rel3 = c.Relation3 //let rel4 = c.Relation4 //let rel5 = c.Relation5 select new { c.Id, Relation = new { rel.Id, rel.Code, }, Relation1 = new { rel1.Id, rel1.Code, } }; ``` This one produces a total of 151 joins on Class2.

Commented Unassigned: Very slow query plan building/outofmemory exception [2560]

$
0
0
Giving the following model:

```
public class BugContext : DbContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);

modelBuilder.Entity<Class1>().HasRequired(c => c.Relation).WithRequiredDependent().WillCascadeOnDelete(false);
modelBuilder.Entity<Class1>().HasRequired(c => c.Relation1).WithRequiredDependent().WillCascadeOnDelete(false);
modelBuilder.Entity<Class1>().HasRequired(c => c.Relation2).WithRequiredDependent().WillCascadeOnDelete(false);
modelBuilder.Entity<Class1>().HasRequired(c => c.Relation3).WithRequiredDependent().WillCascadeOnDelete(false);
modelBuilder.Entity<Class1>().HasRequired(c => c.Relation4).WithRequiredDependent().WillCascadeOnDelete(false);
modelBuilder.Entity<Class1>().HasRequired(c => c.Relation5).WithRequiredDependent().WillCascadeOnDelete(false);
}

public DbSet<Class1> Class1s { get; set; }
}

public class Class1
{
public int Id { get; set; }
public virtual Class2 Relation { get; set; }
public virtual Class2 Relation1 { get; set; }
public virtual Class2 Relation2 { get; set; }
public virtual Class2 Relation3 { get; set; }
public virtual Class2 Relation4 { get; set; }
public virtual Class2 Relation5 { get; set; }
}

public class Class2
{
public int Id { get; set; }

public string Code { get; set; }
}
```

And the following test code
```
using (var context = new BugContext())
{
var query2 = from c in context.Class1s.OrderBy(c => c.Id).Take(100)
let rel = c.Relation
let rel1 = c.Relation1
let rel2 = c.Relation2
let rel3 = c.Relation3
let rel4 = c.Relation4
let rel5 = c.Relation5
select new
{
c.Id,
Relation = new
{
rel.Id,
rel.Code,
},
Relation1 = new
{
rel1.Id,
rel1.Code,
}
};

var sw = Stopwatch.StartNew();
var sql = query2.ToString();
sw.Stop();
Console.WriteLine(sw.Elapsed);
}
```

Produces an out-of-memory exception.
Removing the "let rel5 = c.Relation5" lets the ToString() finish in around 18 secs.
Removing the "let rel4 = c.Relation4" as well brings this down to 2 secs.

As you can see, the relations don't have to be used in the actual projection but using them gives the same results.
This is the smallest version I could build to reproduce the error, the original error came from an EF6 edmx using ObjectContext.

Removing the ".OrderBy(c => c.Id).Take(100)" will let it complete in 100ms.
Comments: My apologies, this is not a correct sample for reproducing the bug I'm trying to log, I thought I had created required relationships but it seems I build something else. Because the long times were correct I thought I had the same conditions. This issue can be closed/deleted, I'll open another one if I have the correct code to reproduce my issue.

Commented Unassigned: Cast introduced in query when using Contains() with Guids that may prevent SQL from using indexes [2552]

$
0
0
This is a very similar issue to [823](https://entityframework.codeplex.com/workitem/823):

Model contains this class:
```
public class Product
{
public Guid Id { get; set; }
}
```

A query like this:
```
List<Guid> params = new List<Guid>();
params.Add(new Guid());
var q = db.Products.Where(c => params.Contains(c.Id));
```
Gets a translation like this:
```
SELECT
[Extent1].[Id] AS [Id],
FROM [dbo].[Products] AS [Extent1]
WHERE [Extent1].[Id] IN (cast('00000000-0000-0000-0000-000000000000' as uniqueidentifier))
```
Although both the parameters and the column are of type Guid/uniqueidentifier. As a consequence of this, there is no way a database server such as SQL Server can take advantage of an index over Products.Id.
Comments: Understood - tested and this is correct.

New Post: Entity Framework source codes does not compile successfully with .NET Framework 4

$
0
0
I want reference to EF source codes projects instead its assemblies in my project for some tracing goals, so I downloaded EF source codes from CodePlex, and add it to my project, it compiles well by .NET Framework 4.5, but my project is in .NET Framework 4, when I change its target framework to .NET 4 it could not compile successfully, I get some errors, e.g:
Error 29 The type or namespace name 'DatabaseGeneratedOption' could not be found (are you missing a using directive or an assembly reference?) C:\Users\8060509\Downloads\entityframework-899f1fb43a0d92c22ea381edafc50a350e391a5a\src\EntityFramework\ModelConfiguration\Configuration\Properties\Primitive\Api\BinaryPropertyConfiguration.cs 102 13 EntityFramework
and
Error 1 The type or namespace name 'ColumnAttribute' could not be found (are you missing a using directive or an assembly reference?) C:\Users\8060509\Downloads\entityframework-899f1fb43a0d92c22ea381edafc50a350e391a5a\src\EntityFramework\ModelConfiguration\Conventions\Configuration\Property\ColumnAttributeConvention.cs 13 61 EntityFramework

New Post: Custom naming for key fields does not work in TPT(Table Per Type) strategy in EF6

Reviewed: EF 6.1.0 (十月 20, 2014)

$
0
0
Rated 5 Stars (out of 5) - Very convenient

Closed Unassigned: Error using Microsoft.SqlServer.Types NuGet Package in published Azure Mobile Service [2311]

$
0
0
Reported via a Blog comment - http://blogs.msdn.com/b/adonet/archive/2013/12/09/microsoft-sqlserver-types-nuget-package-spatial-on-azure.aspx#10529611

everything is working correcty in my local compile however when i publish to azure. I am having the same issue as @Wan

Environment is Azure Mobile Service .net backend

public class WebApiApplication : System.Web.HttpApplication

{

protected void Application_Start()

{

SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));

WebApiConfig.Register();

}

}

the dll's are copy to output director : copy allways

yet after publishing I receive this message in the azure log

Could not load assembly 'D:\home\site\wwwroot\bin\SqlServerTypes\x86\SqlServerSpatial110.dll'. Error received: 'Could not load file or assembly 'file:///D:\home\site\wwwroot\bin\SqlServerTypes\x86\SqlServerSpatial110.dll' or one of its dependencies. The module was expected to contain an assembly manifest.'.

Could not load assembly 'D:\home\site\wwwroot\bin\SqlServerTypes\x86\msvcr100.dll'. Error received: 'Could not load file or assembly 'file:///D:\home\site\wwwroot\bin\SqlServerTypes\x86\msvcr100.dll' or one of its dependencies. The module was expected to contain an assembly manifest.'.

Could not load assembly 'D:\home\site\wwwroot\bin\SqlServerTypes\x64\SqlServerSpatial110.dll'. Error received: 'Could not load file or assembly 'file:///D:\home\site\wwwroot\bin\SqlServerTypes\x64\SqlServerSpatial110.dll' or one of its dependencies. The module was expected to contain an assembly manifest.'.

Could not load assembly 'D:\home\site\wwwroot\bin\SqlServerTypes\x64\msvcr100.dll'. Error received: 'Could not load file or assembly 'file:///D:\home\site\wwwroot\bin\SqlServerTypes\x64\msvcr100.dll' or one of its dependencies. The module was expected to contain an assembly manifest.'.

Edited Unassigned: Error using Microsoft.SqlServer.Types NuGet Package in published Azure Mobile Service [2311]

$
0
0
Reported via a Blog comment - http://blogs.msdn.com/b/adonet/archive/2013/12/09/microsoft-sqlserver-types-nuget-package-spatial-on-azure.aspx#10529611

everything is working correcty in my local compile however when i publish to azure. I am having the same issue as @Wan

Environment is Azure Mobile Service .net backend

public class WebApiApplication : System.Web.HttpApplication

{

protected void Application_Start()

{

SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));

WebApiConfig.Register();

}

}

the dll's are copy to output director : copy allways

yet after publishing I receive this message in the azure log

Could not load assembly 'D:\home\site\wwwroot\bin\SqlServerTypes\x86\SqlServerSpatial110.dll'. Error received: 'Could not load file or assembly 'file:///D:\home\site\wwwroot\bin\SqlServerTypes\x86\SqlServerSpatial110.dll' or one of its dependencies. The module was expected to contain an assembly manifest.'.

Could not load assembly 'D:\home\site\wwwroot\bin\SqlServerTypes\x86\msvcr100.dll'. Error received: 'Could not load file or assembly 'file:///D:\home\site\wwwroot\bin\SqlServerTypes\x86\msvcr100.dll' or one of its dependencies. The module was expected to contain an assembly manifest.'.

Could not load assembly 'D:\home\site\wwwroot\bin\SqlServerTypes\x64\SqlServerSpatial110.dll'. Error received: 'Could not load file or assembly 'file:///D:\home\site\wwwroot\bin\SqlServerTypes\x64\SqlServerSpatial110.dll' or one of its dependencies. The module was expected to contain an assembly manifest.'.

Could not load assembly 'D:\home\site\wwwroot\bin\SqlServerTypes\x64\msvcr100.dll'. Error received: 'Could not load file or assembly 'file:///D:\home\site\wwwroot\bin\SqlServerTypes\x64\msvcr100.dll' or one of its dependencies. The module was expected to contain an assembly manifest.'.


Commented Feature: "SELECT" Stored Procedures in EF (not only for I/U/D) [1772]

$
0
0
...what I mean with SELECT Stored Procedures was to select a SP and the Designer should build the Entity from the result of that SP - all of our Data access goes through Stored Procedures for Select/Insert/Update/Delete and the SELECT result doesn't often map to tables because we return special columns from multiple tables...
Comments: Hey Robert, Taking the typed data set example, you would normally specify which stored procedures can be used to load data for the set and have a function for each of those sprocs that you can call from application code. This is essentially the same functionality that is available in EF with Function Imports. A Function Import gives you a strongly typed method that calls a stored procedure. These functions can return entity types and the results will be tracked etc. as if they were returned from a LINQ query. Here is a screen shot that shows setting one of these up in the EF Designer: So I think the scenario you want is absolutely supported. The one rough edge is that it's harder to create the model when you don't also have a table to reverse engineer from (which was why we left this work item open). So for the moment you would either need to create a temporary table/view to reverse engineer from (or temporarily give the app access to see the tables), or hand edit the xml. Of course, you won't be able to run LINQ queries, since it would try and access a "table" that doesn't exist (or the app doesn't have permission to access). But I think this is fine since composing LINQ queries on a sproc probably isn't a great idea. Does that clear things up? ~Rowan

Commented Feature: "SELECT" Stored Procedures in EF (not only for I/U/D) [1772]

$
0
0
...what I mean with SELECT Stored Procedures was to select a SP and the Designer should build the Entity from the result of that SP - all of our Data access goes through Stored Procedures for Select/Insert/Update/Delete and the SELECT result doesn't often map to tables because we return special columns from multiple tables...
Comments: Hey Robert, Taking the typed data set example, you would normally specify which stored procedures can be used to load data for the set and have a function for each of those sprocs that you can call from application code. This is essentially the same functionality that is available in EF with Function Imports. A Function Import gives you a strongly typed method that calls a stored procedure. These functions can return entity types and the results will be tracked etc. as if they were returned from a LINQ query. Here is a screen shot that shows setting one of these up in the EF Designer: ![Image](https://www.codeplex.com/Download/AttachmentDownload.ashx?ProjectName=entityframework&WorkItemId=1772&FileAttachmentId=922974) So I think the scenario you want is absolutely supported. The one rough edge is that it's harder to create the model when you don't also have a table to reverse engineer from (which was why we left this work item open). So for the moment you would either need to create a temporary table/view to reverse engineer from (or temporarily give the app access to see the tables), or hand edit the xml. Of course, you won't be able to run LINQ queries, since it would try and access a "table" that doesn't exist (or the app doesn't have permission to access). But I think this is fine since composing LINQ queries on a sproc probably isn't a great idea. Does that clear things up? ~Rowan

Source code checked in, #c765339962a32415a3574e4415a3189de71ec0ea

$
0
0
Code Review: CodePlex 2480, 2481: Missing public surface needed to build models programatically. Exposed publicly the EntityContainer constructor, the EntityContainer.AddEntitySetBase and MetadataProperty.CreateAnnotation.

Commented Task: Investigate how to annotate metadata items from public API [2481]

$
0
0
See discussion thread here: https://entityframework.codeplex.com/discussions/562358#post1294335
Comments: commit c765339962a32415a3574e4415a3189de71ec0ea

Edited Task: Investigate how to annotate metadata items from public API [2481]

$
0
0
See discussion thread here: https://entityframework.codeplex.com/discussions/562358#post1294335
Viewing all 10318 articles
Browse latest View live




Latest Images