I have an EF4 model over a SQL Server 2008 db. In my model I have a many to many relationship:
Articles * - * Comments
and
Projects * - * Comments
In my Model, I simply created an association and set it up to many to many. In my db, I then get two additional tables ArticleComments and ProjectComments, which only hold the primarykeys...
Are there any examples/articles on how to use the Entity Framework 4.0 Code First model (no edmx or xml configuration anywhere!!!) that interacts with stored procedures? Another aspect to my requirements is I am using a Repository pattern that uses an IRepository interface to abstract the actual data store (memory, database, xml, etc). ...
Entity Framework 4 - STE - simple DB with single table Blogs having BlogID PK column...
var samplesDbEntities = new SamplesDBEntities();
var blogId = Guid.NewGuid();
samplesDbEntities.Blogs.AddObject(new Blog() { BlogID = blogId });
var objectSetResult = samplesDbEntities.Blogs
.Where(p => p.BlogID...
I have a website where businesses can load items for sale. Then end users can search for that item, and find all the stores that carry it.
Most stores sell more than 100 things, and while I do have a form for inserting a single item, it's tremendously stupid to have only this for businesses to offer things.
My idea is to have an option...
I am really struggling to insert some data into 2 database tables.
I am using Linq over WCF Data Services using Entity Framework 4.
The 2 tables look like this:
CREATE TABLE [dbo].[Accounts] (
[Id] int IDENTITY(1,1) NOT NULL,
[Email] nvarchar(max) NOT NULL,
[Password] nvarchar(max) NOT NULL
);
CREATE TABLE [dbo].[Employ...
I have the following:
Product POCO
ProductConfiguration class for EF code only (CTP3)
Product table in database
ProductCrossSell table in database
My Product and ProductConfiguration class looks like:
public class Product
{
public virtual Guid Id { get; set; }
public virtual string Name { get; set; }
public virtual IColl...
Hi guys,
Please I need help on how to handle CRUD in ef4 way. I started a project on asp.net mvc1 and ef v1 .net 3.5 sp1, but along the line after the release of vs 2010 I converted the application to asp.net mvc2 and ef4 .net4 after some reading on the new features both technologies offers.
Right now am kinda stock as things don't app...
I am writing a T4 template for repositories.
Say we have Customers/Orders/Products tables. We then have CustomerRepo, OrdersRepo, and ProductsRepo.
Is it a good practice to have a generic repo for all of them?
public partial class Repository
{
private IContext context;
public Repository()
{
_Product = new ProductRepo();
_Cu...
Hi,
I'm aware you can map multiple storage tables to a single entity if they have a one-to-one relationship in EF 4.0.
Example:
(storage)
(1)Table: People
Columns: Name, Age
(2)Table: Customers
Columns: Registered
--
Relationship: People <1-1> Customers
(concept)
Entity: Customers
Columns: Name, Age, Registered
I'm wo...
Hi,
I can't figure out how to solve the following problem.
What i need it a relationship from one base class to another, so that every derived class has a relationship with the same table, called 'Item' in my example.
Since this is just an example it doesn't reflect my program. In the real program the relationship with class Item is in...
I have been searching for way to perform a linq query to get an object graph based on a specific child inheritance type. I may have prased this a little wrong, but I will try to explain.
Lets say I have a EF4 model that has a City entity, a subdivision entity, a house entity and a feature entity. The city has a one to many relationshi...
In Entity Framework 4, Code Only (CTP3), how do you set a default value for a property in the POCO's EntityConfiguration class?
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
public DateTime CreatedOn { get; set; }
}
public class PersonConfiguration : EntityConfiguration<Person>
{
public PersonCo...
Entity framework maps DB types to .NET types, for instance SQL Server's BigInt is mapped to .NET's long.
Is it possible to create a new type and have a store type (such as BigInt or VarChar) mapped to it? If so, how?
FYI, my goal is to change the way the .NET scalar writes its value to the query, and specifically the way its default v...
I have two development teams, that come from different groups. Group A develops against a local default instance of Sql Server 2008 R2; Group B develops against a local named instance of Sql Server 2008 R2.
Is there a way to setup an alias such that both groups are coding against the same name. As it stands right now we have a war o...
I'm using Entity Framework 4. I'm not really sure where the responsibility of setting a user's password should be. I thought about on the Repository like SetPassword(User user, string password). But it doesn't seem right.
The main problem is that it can't just be a simple property setter since I also return the salt that's generated.
...
I have a user entity with the following properties that map to a field in the database:
Id int
Username varchar(25)
Password binary(64)
Salt binary(64)
Name varchar(50)
Locked bit
What I don't want to do is always return the Password and Salt for every query. But for certain queries, I do want...
Is it possible to call a SSDL function from within another SSDL function's CommandText? For example, let's say I have the following SSDL function defined in my edmx file:
<Function Name="blah" IsComposable="false">
<CommandText>
...blah related stuff...
</CommandText>
<Parameter Name="blah_param" Type="int" />
</Function>
C...
Hi,
I'm using code-first in entity-framework 4, Entity Framework Feature CTP 3
Is it possible to specify an entity configuration's name? In effect changing the table name from 'xxxSet' to a name of my choice?
...
Hi,
I've found various snippets on the web of how to use Code First in EF4 (from the futures CTP).
But I have yet to find a complete example of an object context, the context builder and a more advanced EntityConfiguration.
For example, in my entity configuration, how do I map a property on my domain object to a column with a differen...
How do you represent a many-to-many relationship in the EF4 Code-First CTP3?
For example if I have the following classes:
class User
{
public int Id { get; set; }
public string Name { get; set; }
public ICollection<Profile> Profiles { get; set; }
}
class Profile
{
public int Id { get; set; }
public string Name { ge...