Search Results

Search found 231 results on 10 pages for 'ef4'.

Page 3/10 | < Previous Page | 1 2 3 4 5 6 7 8 9 10  | Next Page >

  • EF4 generates invalid script

    - by Jaxidian
    When I right-click in a .EDMX file and click Generate Database From Model, the resulting script is obviously wrong because of the table names. What it generates is the following script. Note the table names in the DROP TABLE part versus the CREATE TABLE part. Why is this inconsistent? This is obviously not a reusable script. What I created was an Entity named "Address" and an Entity named "Company", etc (all singular). The EntitySet names are pluralized. The "Pluralize New Objects" boolean does not change this either. So what's the deal? For what it's worth, I originally generated the EDMX by pointing it to a database that had tables with non-pluralized names and now that I've made some changes, I want to go back the other way. I'd like to have the option to go back and forth as neither the db-first nor the model-first model is ideal in all scenarios, and I have the control to ensure that there will be no merging issues from multiple people going both ways at the same time. -- -------------------------------------------------- -- Dropping existing FOREIGN KEY constraints -- NOTE: if the constraint does not exist, an ignorable error will be reported. -- -------------------------------------------------- ALTER TABLE [Address] DROP CONSTRAINT [FK_Address_StateID-State_ID]; GO ALTER TABLE [Company] DROP CONSTRAINT [FK_Company_AddressID-Address_ID]; GO ALTER TABLE [Employee] DROP CONSTRAINT [FK_Employee_BossEmployeeID-Employee_ID]; GO ALTER TABLE [Employee] DROP CONSTRAINT [FK_Employee_CompanyID-Company_ID]; GO ALTER TABLE [Employee] DROP CONSTRAINT [FK_Employee_PersonID-Person_ID]; GO ALTER TABLE [Person] DROP CONSTRAINT [FK_Person_AddressID-Address_ID]; GO -- -------------------------------------------------- -- Dropping existing tables -- NOTE: if the table does not exist, an ignorable error will be reported. -- -------------------------------------------------- DROP TABLE [Address]; GO DROP TABLE [Company]; GO DROP TABLE [Employee]; GO DROP TABLE [Person]; GO DROP TABLE [State]; GO -- -------------------------------------------------- -- Creating all tables -- -------------------------------------------------- -- Creating table 'Addresses' CREATE TABLE [Addresses] ( [ID] int IDENTITY(1,1) NOT NULL, [StreetAddress] nvarchar(100) NOT NULL, [City] nvarchar(100) NOT NULL, [StateID] int NOT NULL, [Zip] nvarchar(10) NOT NULL ); GO -- Creating table 'Companies' CREATE TABLE [Companies] ( [ID] int IDENTITY(1,1) NOT NULL, [Name] nvarchar(100) NOT NULL, [AddressID] int NOT NULL ); GO -- Creating table 'People' CREATE TABLE [People] ( [ID] int IDENTITY(1,1) NOT NULL, [FirstName] nvarchar(100) NOT NULL, [LastName] nvarchar(100) NOT NULL, [AddressID] int NOT NULL ); GO -- Creating table 'States' CREATE TABLE [States] ( [ID] int IDENTITY(1,1) NOT NULL, [Name] nvarchar(100) NOT NULL, [Abbreviation] nvarchar(2) NOT NULL ); GO -- Creating table 'Employees' CREATE TABLE [Employees] ( [ID] int IDENTITY(1,1) NOT NULL, [PersonID] int NOT NULL, [CompanyID] int NOT NULL, [Position] nvarchar(100) NOT NULL, [BossEmployeeID] int NULL ); GO -- -------------------------------------------------- -- Creating all PRIMARY KEY constraints -- -------------------------------------------------- -- Creating primary key on [ID] in table 'Addresses' ALTER TABLE [Addresses] ADD CONSTRAINT [PK_Addresses] PRIMARY KEY ([ID] ); GO -- Creating primary key on [ID] in table 'Companies' ALTER TABLE [Companies] ADD CONSTRAINT [PK_Companies] PRIMARY KEY ([ID] ); GO -- Creating primary key on [ID] in table 'People' ALTER TABLE [People] ADD CONSTRAINT [PK_People] PRIMARY KEY ([ID] ); GO -- Creating primary key on [ID] in table 'States' ALTER TABLE [States] ADD CONSTRAINT [PK_States] PRIMARY KEY ([ID] ); GO -- Creating primary key on [ID] in table 'Employees' ALTER TABLE [Employees] ADD CONSTRAINT [PK_Employees] PRIMARY KEY ([ID] ); GO -- -------------------------------------------------- -- Creating all FOREIGN KEY constraints -- -------------------------------------------------- -- Creating foreign key on [StateID] in table 'Addresses' ALTER TABLE [Addresses] ADD CONSTRAINT [FK_Address_StateID_State_ID] FOREIGN KEY ([StateID]) REFERENCES [States] ([ID]) ON DELETE NO ACTION ON UPDATE NO ACTION; -- Creating non-clustered index for FOREIGN KEY 'FK_Address_StateID_State_ID' CREATE INDEX [IX_FK_Address_StateID_State_ID] ON [Addresses] ([StateID]); GO -- Creating foreign key on [AddressID] in table 'Companies' ALTER TABLE [Companies] ADD CONSTRAINT [FK_Company_AddressID_Address_ID] FOREIGN KEY ([AddressID]) REFERENCES [Addresses] ([ID]) ON DELETE NO ACTION ON UPDATE NO ACTION; -- Creating non-clustered index for FOREIGN KEY 'FK_Company_AddressID_Address_ID' CREATE INDEX [IX_FK_Company_AddressID_Address_ID] ON [Companies] ([AddressID]); GO -- Creating foreign key on [AddressID] in table 'People' ALTER TABLE [People] ADD CONSTRAINT [FK_Person_AddressID_Address_ID] FOREIGN KEY ([AddressID]) REFERENCES [Addresses] ([ID]) ON DELETE NO ACTION ON UPDATE NO ACTION; -- Creating non-clustered index for FOREIGN KEY 'FK_Person_AddressID_Address_ID' CREATE INDEX [IX_FK_Person_AddressID_Address_ID] ON [People] ([AddressID]); GO -- Creating foreign key on [CompanyID] in table 'Employees' ALTER TABLE [Employees] ADD CONSTRAINT [FK_Employee_CompanyID_Company_ID] FOREIGN KEY ([CompanyID]) REFERENCES [Companies] ([ID]) ON DELETE NO ACTION ON UPDATE NO ACTION; -- Creating non-clustered index for FOREIGN KEY 'FK_Employee_CompanyID_Company_ID' CREATE INDEX [IX_FK_Employee_CompanyID_Company_ID] ON [Employees] ([CompanyID]); GO -- Creating foreign key on [BossEmployeeID] in table 'Employees' ALTER TABLE [Employees] ADD CONSTRAINT [FK_Employee_BossEmployeeID_Employee_ID] FOREIGN KEY ([BossEmployeeID]) REFERENCES [Employees] ([ID]) ON DELETE NO ACTION ON UPDATE NO ACTION; -- Creating non-clustered index for FOREIGN KEY 'FK_Employee_BossEmployeeID_Employee_ID' CREATE INDEX [IX_FK_Employee_BossEmployeeID_Employee_ID] ON [Employees] ([BossEmployeeID]); GO -- Creating foreign key on [PersonID] in table 'Employees' ALTER TABLE [Employees] ADD CONSTRAINT [FK_Employee_PersonID_Person_ID] FOREIGN KEY ([PersonID]) REFERENCES [People] ([ID]) ON DELETE NO ACTION ON UPDATE NO ACTION; -- Creating non-clustered index for FOREIGN KEY 'FK_Employee_PersonID_Person_ID' CREATE INDEX [IX_FK_Employee_PersonID_Person_ID] ON [Employees] ([PersonID]); GO -- -------------------------------------------------- -- Script has ended -- --------------------------------------------------

    Read the article

  • many-to-many, poco, ef4

    - by Lari13
    I have 3 entities: Goods [GID(PK), GoodName] Persons [PID(PK), PersonName] Roles [RID(PK), RoleName] But now I need to associate these object with each other. In other words, each Good can have MANY Persons in MANY Roles. For example: Book (GID#1), can have 3 associated persons: 1. Jack (PID#1) in role Author (RID#1) 2. Jack (PID#1) in role Editor (RID#2) 3. Bill (PID#2) in role Painter (RID#3) How can it be done in POCO format in Entity Framework 4?

    Read the article

  • Generate EF4 POCO classes first time only

    - by Jaxidian
    The problem I'm having is, using the POCO templates, generating my POCO classes the first time only and not overwriting them when the templates are re-ran. I know this sounds hokey and the reason is that I'm actually changing these templates and trying to generate metadata classes rather than the actual POCO classes, but these metadata classes will be hand-edited and I want to keep those edits in the future but still regenerate a certain amount of it. I have it all working exactly as I want except for the regeneration of the files. I have looked into T4 and it seems that there is a flag to do just this (see the Output.PreserveExistingFile property) but I don't understand where/how to set this flag. If you can tell me where/how to set this in the default POCO templates, then I think that's all I really need. Thanks!! :-)

    Read the article

  • EF4: ObjectContext inconsistent when inserting into a view with triggers

    - by user613567
    I get an Invalid Operation Exception when inserting records in a View that uses “Instead of” triggers in SQL Server with ADO.NET Entity Framework 4. The error message says: {"The changes to the database were committed successfully, but an error occurred while updating the object context. The ObjectContext might be in an inconsistent state. Inner exception message: The key-value pairs that define an EntityKey cannot be null or empty. Parameter name: record"} @ at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options) at System.Data.Objects.ObjectContext.SaveChanges() In this simplified example I created two tables, Contacts and Employers, and one view Contacts_x_Employers which allows me to insert or retrieve rows into/from these two tables at once. The Tables only have a Name and an ID attributes and the view is based on a join of both: CREATE VIEW [dbo].[Contacts_x_Employers] AS SELECT dbo.Contacts.ContactName, dbo.Employers.EmployerName FROM dbo.Contacts INNER JOIN dbo.Employers ON dbo.Contacts.EmployerID = dbo.Employers.EmployerID And has this trigger: Create TRIGGER C_x_E_Inserts ON Contacts_x_Employers INSTEAD of INSERT AS BEGIN SET NOCOUNT ON; insert into Employers (EmployerName) select i.EmployerName from inserted i where not i.EmployerName in (select EmployerName from Employers) insert into Contacts (ContactName, EmployerID) select i.ContactName, e.EmployerID from inserted i inner join employers e on i.EmployerName = e.EmployerName; END GO The .NET Code follows: using (var Context = new TriggersTestEntities()) { Contacts_x_Employers CE1 = new Contacts_x_Employers(); CE1.ContactName = "J"; CE1.EmployerName = "T"; Contacts_x_Employers CE2 = new Contacts_x_Employers(); CE1.ContactName = "W"; CE1.EmployerName = "C"; Context.Contacts_x_Employers.AddObject(CE1); Context.Contacts_x_Employers.AddObject(CE2); Context.SaveChanges(); //? line with error } SSDL and CSDL (the view nodes): <EntityType Name="Contacts_x_Employers"> <Key> <PropertyRef Name="ContactName" /> <PropertyRef Name="EmployerName" /> </Key> <Property Name="ContactName" Type="varchar" Nullable="false" MaxLength="50" /> <Property Name="EmployerName" Type="varchar" Nullable="false" MaxLength="50" /> </EntityType> <EntityType Name="Contacts_x_Employers"> <Key> <PropertyRef Name="ContactName" /> <PropertyRef Name="EmployerName" /> </Key> <Property Name="ContactName" Type="String" Nullable="false" MaxLength="50" Unicode="false" FixedLength="false" /> <Property Name="EmployerName" Type="String" Nullable="false" MaxLength="50" Unicode="false" FixedLength="false" /> </EntityType> The Visual Studio solution and the SQL Scripts to re-create the whole application can be found in the TestViewTrggers.zip at ftp://JulioSantos.com/files/TriggerBug/. I appreciate any assistance that can be provided. I already spent days working on this problem.

    Read the article

  • Preventing EF4 ConstraintException when invoking TryUpdateModel

    - by twk
    Given following ASP.NET MVC controller code: [HttpPost] public ActionResult Create(FormCollection collection) { string[] whitelist = new []{ "CompanyName", "Address1", "Address2", ... }; Partner newPartner = new Partner(); if (TryUpdateModel(newPartner, whitelist, collection)) { var db = new mainEntities(); db.Partners.AddObject(newPartner); db.SaveChanges(); return RedirectToAction("Details/" + newPartner.ID); } else { return View(); } } The problem is with the Entity Framework 4: the example Partner entity is mapped to a database table with it's fields NOT ALLOWED to be NULL (which is ok by design - they're required). Unfortunately, invoking TryUpdateModel when some of the properties are nulls produces ConstraintException which is not expected! I do expect that TryUpdateModel return false in this case. It is ok that EF wouldn't allow set a property value to null if it should not be, but the TryUpdateMethod should handle that, and add the error to ModelState errors collection. I am wrong, or somebody screwed the implementation of TryUpdateModel method?

    Read the article

  • EF4 - What's all the hype over objectsets?

    - by Kohan
    I am an intermediate user of EF in .net 3.5 and have recently moved to working with .net 4. One think i keep coming across when reading various tutorials is the use of ObjectSets instead of ObjectQuerys and that they are a great new feature. What is so great about them? Reading this MSDN article titled "Working with ObjectSet (Entity Framework)" It shows two examples for on how to add a Product.. one for 3.5 and another for 4.0. http://msdn.microsoft.com/en-us/library/ee473442.aspx Though my lack of knowledge I am possibly bringing up a seperate point here, but i never added a Product like this: //In .NET Framework 3.5 SP1, use the following code: using (AdventureWorksEntities context = new AdventureWorksEntities()) { // Add the new object to the context. context.AddObject("Products", newProduct); } I would have just used context.AddToProducts(newProduct); Please enlighten me. Kind regards, Kohan

    Read the article

  • EF4: common interface for EF entities

    - by Feryt
    Hi. I have public interface: public interface IEntity { int ID { get; set; } string Name { get; set; } bool IsEnabled { get; set; } } ehich some EF entities implements(thanks to partial class) and extesion method: public static IEnumerable<SelectListItem> ToSelectListItems<T>(this IQueryable<T> entities, int? selectedID = null) where T : IEntity { return entities.Select(c => new { c.Name, c.ID }).ToList().Select(c => new SelectListItem { Text = c.Name, Value = c.ID.ToString(), Selected = (c.ID == selectedID) }); } Calling ToSelectListItems return exception: Unable to cast the type '<EF entity name>' to type 'IEntity'. LINQ to Entities only supports casting Entity Data Model primitive types. Why, any ideas? Thank you.

    Read the article

  • Is EF4 "Code Only" ready for production use?

    - by Tommy Jakobsen
    I've been looking at the new Entity Framework 4 Code Only features, and I really like them. But I'm having a hard time finding good resource on the feature. Everything seems to be spread around blongs here and there, so this make me wonder if it's ready to be used for a serious project? What do you think? Is it ready for production use or should I use the more traditional approach (EDMX designer, POCO objects)? Also, I would like to know if there are any features that Code Only does not support yet, compared to the EDMX designer? What do you think about the Code Only feature? Is it "mature" yet? Thank you.

    Read the article

  • beginner Linq syntax and EF4 question

    - by user564577
    Question With the following linq code snip I get a list of clients with address filtered by the specifications but the form of the entities returned is not what i had expected. The data is 1 client with 2 addresses and 1 client with 1 address. The query returns 3 rows of clients each with 1 address Client 1 = Address1 Client 1 = Address2 Client 2 = Address3 var query = from t1 in context.Clients.Where(specification.SatisfiedBy()).Include("ClientAddresses") join t2 in context.ClientAddresses.Where(spec.SatisfiedBy()) on t1.ClientKey equals t2.ClientKey select t1; My expectation was a little more like a list with only two clients in it, one client with a collection of two addresses and one client with a collection of one address. Client 1 = Address1 / Address2 Client 2 = Address3 What am I missing??? Thanks!

    Read the article

  • EF4 querying through the generations

    - by Hans Kesting
    I have a model withs Parents, Children and Grandchildren, in a many-to-many relationship. Using this article I created POCO classes that work fine, except for one thing I can't yet figure out. When I query the Parents or Children directly using LINQ, the SQL reflects the LINQ query (a .Count() executes a COUNT in the database and so on) - fine. The Parent class has a Children property, to access it's children. But (and now for the problem) this doesn't expose an IQueryable interface but an ICollection. So when I access the Children property on a particular parent all the Parent's Children are read. Even worse, when I access the Grandchildren (theParent.Children.SelectMany(child => child.GrandChildren).Count()) then for each and every child a separate request is issued to select it's grandchildren. Changing the type of the Children property from ICollection to IQueryable doesn't solve this. Apart from missing needed methods like Add() and Remove(), EF just doesn't recognize the property then. Are there correct ways (as in: low database interaction) of querying through children (and what are they)? Or is this just not possible?

    Read the article

  • EF4 (CPT5) ForeignKeyAttribute in base class - Assert Failure entityType != null

    - by Anthony Johnston
    Getting an error when trying to set a ForeignKeyAttribute in a base class class User{} abstract class FruitBase{ [ForeignKey("CreateById")] public User CreateBy{ get; set; } public int CreateById{ get; set; } } class Banana{} class DataContext : DbContext{ DbSet<Banana> Bananas{ get; set; } } If I move the FruitBase code into the banana, all is well, but I don't want to, as there will be many many fruit and I want to remain relatively DRY if I can Is this a know issue that will be fixed by March? Does anyone know a work around?

    Read the article

  • Disable lazy loading by default in Entity Framework 4

    - by Mikey Cee
    It seems that lazy loading is enabled by default in EF4. At least, in my project, I can see that the value of dataContext.ContextOptions.LazyLoadingEnabled is true by default. I don't want lazy loading and I don't want to have to write: dataContext.ContextOptions.LazyLoadingEnabled = false; each time I get a new context. So is there a way to turn it off by default, say, across the whole project?

    Read the article

  • EDM -> POCO -> WCF (.NET4) But transferring Collections causes IsReadOnly set to TRUE

    - by Gary B
    Ok, this may sound a little 'unorthodox', but...using VS2010 and the new POCO t4 template for Entity Framework (http://tinyurl.com/y8wnkt2), I can generate nice POCO's. I can then use these POCO's (as DTO's) in a WCF service essentially going from EDM all the way through to the client. Kinda what this guys is doing (http://tinyurl.com/yb4bslv), except everything is generated automatically. I understand that an entity and a DTO 'should' be different, but in this case, I'm handling client and server, and there's some real advantages to having the DTO in the model and automatically generated. My problem is, that when I transfer an entity that has a relationship, the client generated collection (ICollection) has the read-only value set, so I can't manipulate that relationship. For example, retrieving an existing Order, I can't add a product to the Products collection client-side...the Products collection is read-only. I would prefer to do a bunch of client side 'order-editing' and then send the updated order back rather than making dozens of server round trips (eg AddProductToOrder(product)). I'd also prefer not to have a bunch of thunking between Entity and DTO. So all-in-all this looks good to me...except for the read-only part. Is there a solution, or is this too much against the SOA grain?

    Read the article

  • code first CTP5 error message

    - by user482833
    I get the following error message with a new project I have set using code first CTP5. Can't find anything on the web about it. Has anyone encountered this error message? The context cannot be used while the model is being created. This occurs the first time my database context is called (code below): using (StaffData context = new StaffData()) { return context.Employees.Count(e = e.EmployeeReference) == 1; } At this point the database has not been created. I have a database initialiser DropCreateDatabaseIfModelChanges which I set in app_start.

    Read the article

  • What is the proper way to handle non-tracking self tracking entities?

    - by Will
    Self tracking entities. Awesome. Except when you do something like return Db.Users; none of the self-tracking entities are tracking (until, possibly, they are deserialized). Fine. So we have to recognize that there is a possibility that an entity returning to us does not have tracking enabled. Now what??? Things I have tried For the given method body: using (var db = new Database()) { if (update.ChangeTracker.ChangeTrackingEnabled) db.Configurations.ApplyChanges(update); else FigureItOut(update, db); db.SaveChanges(); update.AcceptChanges(); } The following implementations of FigureItOut all fail: db.Configurations.Attach(update); db.DetectChanges(); Nor db.Configurations.Attach(update); db.Configurations.ApplyCurrentValues(update); Nor db.Configurations.Attach(update); db.Configurations.ApplyOriginalValues(update); Nor db.Configurations.Attach(update); db.Configurations.ApplyChanges(update Nor about anything else I can figure to throw at it, other than Getting the original entity from the database Comparing each property by hand Updating properties as needed What, exactly, am I supposed to do with self-tracking entities that aren't tracking themselves??

    Read the article

  • Best way to implement nested loops in a view in asp.net mvc 2

    - by Junior Ewing
    Hi, Trying to implement some nested loops that are spitting out good old nested html table data. So the question is; What is the best way to loop through lists and nested lists in order to produce easily maintainable code. It can get quite narly quite fast when working with multiple nested tables or lists. Should I make use of a HTML helper, or make something with the ViewModel to simplify this? A requirement is if there are no children at a node there should be an empty row on that spot with some links for creation and into other parts of the system.

    Read the article

  • Using T4 templates to add custom code to EF4 generated entities?

    - by David Veeneman
    I am getting started with Entity Framework 4, using model-first development. I am building a simple WPF demo app to learn the framework. My app has two entities, Topic and Note. A Topic is a discussion topic; it has Title, Text, and DateRevised properties. Topic also has a Notes collection property. a Note has DateCreated and Text properties. I have used EF4 to create an EDM and data store for the app. Now I need to add just a bit of intelligence to the entities. For example, the property setter for the Topic.Text property needs to update the Topic.DateRevised property, and a Note needs to set its DateCreated property when it is instantiated--pretty simple stuff. I assume that I can't modify the generated classes directly, because my code would be lost if the entities are re-generated. Is this the sort of thing that I can implement by modifying the T4 template that EF4 uses to generate the entities? In other words, can a T4 template be modified to add my code for performing these tasks to the entities that it generates? Can you refer me to a good tutorial or explanation of how to get started? Most of what I have found so far talks about how to add a tt file to an EDM, so I can do that. What I am looking for is a resource that I can use to get to the next level, assuming that a T4 template can be used to customize generated entities as I have described. Thanks for your help.

    Read the article

  • GUID or int entity key with SQL Compact/EF4?

    - by David Veeneman
    This is a follow-up to an earlier question I posted on EF4 entity keys with SQL Compact. SQL Compact doesn't allow server-generated identity keys, so I am left with creating my own keys as objects are added to the ObjectContext. My first choice would be an integer key, and the previous answer linked to a blog post that shows an extension method that uses the Max operator with a selector expression to find the next available key: public static TResult NextId<TSource, TResult>(this ObjectSet<TSource> table, Expression<Func<TSource, TResult>> selector) where TSource : class { TResult lastId = table.Any() ? table.Max(selector) : default(TResult); if (lastId is int) { lastId = (TResult)(object)(((int)(object)lastId) + 1); } return lastId; } Here's my take on the extension method: It will work fine if the ObjectContext that I am working with has an unfiltered entity set. In that case, the ObjectContext will contain all rows from the data table, and I will get an accurate result. But if the entity set is the result of a query filter, the method will return the last entity key in the filtered entity set, which will not necessarily be the last key in the data table. So I think the extension method won't really work. At this point, the obvious solution seems to be to simply use a GUID as the entity key. That way, I only need to call Guid.NewGuid() method to set the ID property before I add a new entity to my ObjectContext. Here is my question: Is there a simple way of getting the last primary key in the data store from EF4 (without having to create a second ObjectContext for that purpose)? Any other reason not to take the easy way out and simply use a GUID? Thanks for your help.

    Read the article

  • EF4. Add a object with relationship causes full table select

    - by Fujiy
    Ex 1: "autor.ComentariosWorkItens.Add(comentarioWorkItem);" autor.ComentariosWorkItens makes EF4 load all ComentariosWorkItens. Ex 2: comentarioWorkItem.Usuario = autor; Fixup make EF load all ComentariosWorkItens too: private void FixupUsuario(Usuario previousValue) { if (previousValue != null && previousValue.ComentariosWorkItens.Contains(this)) { previousValue.ComentariosWorkItens.Remove(this); } if (Usuario != null) { if (!Usuario.ComentariosWorkItens.Contains(this)) { Usuario.ComentariosWorkItens.Add(this); } } } How can I prevent this?

    Read the article

  • How do I verify my EF4 Code-Only mappings?

    - by Tomas Lycken
    In NHibernate, there is a method doing something like ThisOrThat.VeryfyMappings() (I don't know the exact definition of it since it was a while ago I last tried NHibernate...) I recall seeing a blog post somewhere where the author showed how to do some similar testing in Entity Framework 4, but now I cant find it. So, how do I test my EF4 Code-Only mappings?

    Read the article

  • "Metadata information not found" while using EF4's POCO Template?

    - by ladenedge
    I just installed the POCO Template for EF4. I have a single entity in my model, AnnouncementText, and the T4 files seem to be properly generated. Attempting to access this new entity is throwing the following error when I access the auto-generated property MyObjectContext.AnnouncementTexts: InvalidOperationException: Mapping and metadata information could not be found for EntityType 'MyNamespace.AnnouncementText'. The properties on the AnnouncementText POCO seem to match up with the columns in the database, and I haven't changed any of the auto-generated code. The stack trace is: at System.Data.Objects.ObjectContext.GetTypeUsage(Type entityCLRType) at System.Data.Objects.ObjectContext.GetEntitySetForNameAndType(String entitySetName, Type entityCLRType, String exceptionParameterName) at System.Data.Objects.ObjectContext.CreateObjectSet[TEntity](String entitySetName) at MyNamespace.MyObjectContext.get_AnnouncementTexts() in C:\<snip>\MyObjectContext.Context.cs:line 65 at MyNamespace.Class1.Main() in C:\<snip>\Class1.cs:line 14 If I delete the .tt files from the solution and enable code generation on the model, I am able to access the property without issue. Here's my code, in case that might help: using (var context = new MyObjectContext()) foreach (var at in context.AnnouncementTexts) Console.WriteLine(at.Title); Any ideas on what might be wrong?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10  | Next Page >