Hi all,
I've got the following model and I want ShiftRequest and MissionRequest to have a single table in the DB.
public class RequestBase
{
public int Id { get; set; }
public DateTime? RequestDate { get; set; }
public int UserId { get; set; }
public virtual ICollection<Notification> Notificatio...
What are the best practices for database refactoring with codefirst EF4?
I am interested to hear how people change the classes and the database when the RecreateDatabaseIfModelChanges option is not feasible. Migration of data will need to occur.
Currently Microsoft has a solution for doing this with model first:
http://blogs.msdn.com...
How do I make non persisted properties using codefirst EF4?
MS says there is a StoreIgnore Attribute, but I cannot find it.
http://blogs.msdn.com/b/efdesign/archive/2010/03/30/data-annotations-in-the-entity-framework-and-code-first.aspx
Is there a way to set this up using EntityConfiguration?
...
How can you map an entity to a database view with EF 4 code first?
Is there a way to do this by deriving from the EntityConfiguration classes?
...
I have a large table that I want to map to a few entities.
Say the table looks like this: Thing(ThingId, Property1...Property20)
Now I have my entities:
public abstract class ThingBase
{
public int ThingId { get; set; }
public string Property1 { get; set; }
public string Property2 { get; set; }
}
public class ThingSummary...
How to declare a one to one relationship using Entity Framework 4 Code First (POCO)?
I found this question http://stackoverflow.com/questions/2089395/one-to-one-relationships-in-entity-framework-4-v2-with-poco, but the article that the answer references was not useful (there is one line of code that is a 1-1 relationship, but no mention...
If I have an entity that has an association (e.g. Book.Publisher), how do I save a new Book and associate it with an existing Publisher?
BTW I don't want to expose FK associations (i.e. PublisherId) in my model.
I had been using something like this:
var book = new Book { Title="whatever", Publisher = new Publisher { Id = 42 } };
cont...
Hi,
I wonder if someone can help me.
I'm using VS2010, .Net 4, EF4 and I'm trying to generate an objectcontext which is configured entirely in code (code-only as opposed to model-first or db-first).
In short, I do:
Create a ContextBuilder
Configure ContextBuilder for each entity (specifying PK, FKs, Nullable, etc.)
I ask the Contex...
Hi,
We've got the following scenario:
Central Database (replicated across multiple servers)
Client Database 1
Client Database 2
The Central db has Users and Roles amongst other things
The Client dbs have similar tables to each other but with some fields tweaked - contact, address, etc...
At present, each client db has its own user/r...
Hi I am using Entity Framework code only from CTP4. My question is this: given the name of a domain class which is mapped using an EntityConfiguration how can I retrieve the table name for the mapped class at runtime? I'm assuming I need to be using the MetadataWorkspace on the ObjectContext, but finding it difficult to get up-to-date ...
Has anyone advice when working with large database models when using EF4 code first? Entity sets are added to the database context, but if I have 100 tables, I need to create 100 DbSets, 1 for each table:
public class Customers : DbContext
{
public DbSet<Customer> Customers {get; set;}
public DbSet<Employees> Employees {get; set...
I am having a lot of trouble with 'base types' in the Code Only model of the Entity Framework. I am having a lot of trouble with 'base types' in the Code Only model of the Entity Framework.
When I try to run this code using a DbContext with a DbSet<Template>, I get the following error.
A The navigation property 'Flags' is mapped t...
I am using EF4 code first and want to generate a composite key which is made of a class property and foreign key. I have two classes: Order and Company. The Order class holds a reference but this will not necessarily be unique between companies. So I intend to use a composite key made up of Reference and Company.CompanyId.
I have tried ...
Hi,
I have a table like this:
Name
Tree
Iron
Clay
Added
I want to map it to a model like this:
Name
Resources
Tree
Iron
Clay
Added
In makes sense to map it like this, when working with it in my program, but doing it that way in the databse would just make it more complex ... not would not add any useful things.
Is it possible...