cannot create database from ERD - erd

Ive got ERD in visual paradigm and I want to generate postgreSQL database from it.
When I try generate database Ive got error:
Fail to generate database due to no physical entity in the project. (Error Code: DB0001).
I already tried to synchronize ERD with class diagram, but it didnt help.

It looks like your ERD is either in Conceptual or Logical data model. In Visual Paradigm the generation of database is only apply to Physical data model. You can right click on the blank area of your ERD and select Open Specification, and then specify the Data model to Physical for generating database.
Or if you wish to keep your Conceptual/Logical ERD, you can then follow the video below about how to generate Physical ERD from your existing Conceptual/Logical ERD for generating database.
How to Generate Physical ERD from Conceptual ERD

Related

Entity Framework: association between two edmx models

I have a bigger project that uses multiple edmx files to manage the data model for an asp.net application. What I want to achieve is to link two entities accross two edmx models.
So basically, just a foreign key like this: EntityA.ForeignEntityId --> EntityB.Id
However, since the enitites are not in the same model, I cannot add this foreign key in the model designer. I know that I could do it manually by either modifying the auto-generated SQL-file or by adding the relation in the SQL Server Manager. Both these approaches have the massive downside that they are not easily maintainable because if I do "Create database from model" and run the resulting SQL script, my manual modifications are dropped (I thnink?).
So is there a way of referencing a foreign entity from another edmx model in the model designer?
I know this is old but i found myself with the same problem. If you create the reference in SQL and update your model from the database it will pull in the table that is referenced. I don't think this really solves the problem we have but it will at least allow for you to go back and forth without losing any FKs.

Cannot add new tables via Entity Framework

I'm encountering a very odd problem. Since 2 days I cannot add new tables from my db in the model.
They appear in the list of addable tables, no error are shown at the validation but then, they don't appear in the Entity lists, and they still appear in the "addable" part of the menu.
The problem appears in
We've tried from different computeurs, so it's not a problem of my specific visual studio.
We've tried with other dbs, and the problem doesn't affect them. It affects boths of my prod and developpment dbs though.
We've tried with the exact same credentials to log to the db (not window authentication as we usually do), and the problem remains, so it's not a problem of rights.
We're a bit out of ideas right now :/
Does someone have an idea what it could be?
Thanks
Ok, we've found where it came from.
The table we wanted to add had no PK, and then when we tested we created mock tables without PK.
Once we add a PK the import goes well =)
If you're using a Code First approach then Entity Framework will build the table for you. It looks like you are not using Code First, so you will have create the table in the database. I assume you're using an Entity Data Model (.edmx)? If so, you will create your table in the database, then update your data model (.edmx). If you have not yet created your .edmx file, you need to do that - the .edmx file will contain all your CRUD operations.
What I'm confused about is I'd imagine your code would throw an error if the table did not exist (i.e. if the table represented by your data model didn't map to an actual table in the database, because it doesn't exist). So, the question is, does your table already exist? If it does, then step through the code line by line to find out why your records aren't being saved. If it doesn't exist, then add the table via SQL Server Management Studio (or similar), then open your .edmx file, right click on the layout that comes up, click "Update Model from database".

Two identical dbml data context's in one asp.net application

I have a separate copy of a sql server2008 database that we used to isolate data. I would now like to bring a few records into the production database from this separate database. I am not sure of the best way to do this, but I need to transfer several tables and ensure the relations remain. The easiest way I think of is to (if possible) create another dbml data context of the separate database and set all variables equal to a new object in the new database. I realized that I am getting many conflict errors. Is there a way to have two databases coexist like this in one application? There a few minor differences in the databases. The production database does have a few added rows.
Thank you for the help,
Chris
I'm no authority so perhaps someone can give you a better solution but it seems you can't have two models in the same project with an identical table name. What you could do is create a new project in your solution just to contain the model for the separate database.
This will let you have two models that both contain a "person" object for example because their namespaces will be different. Might help to put using statements at the top of your pages that use both models similar to the below:
using PersonLive = MyProject.Person;
using PersonIsolation = AlternateProject.Person;

sql server database diagram

I created a database mdf file a while back and created a diagram of foreign keys. Lately, I needed to add several tables and there was an error saying I couldn't do the diagram because I'm not the owner.
So, I didn't update the diagram but added the tables anyway. My app seems to be working fine with the new tables. I'm using linq-to-sql and the design surface of the ORM doesn't show the connection between the new and the old tables.
My question is this: if the app works both with and without the diagram, what's the benefit of creating one? I know I can read an 800-page book and get the answer but I was wondering what the 2-3 line answer would be.
Thanks.
Diagram is just modeling tool.. no need to use it, but cool to visualise db, easier to write queries if you're not creator of db.
You can switch owner of db in options at "File" tab.

Creating complex object using POCO in EF

I am trying to understand how to create a complex POCO which in the backend tied to a stored procedure or multiple tables. All the examples I have seen are simple one table to one entity or two tables. Could some one point me to a link or example on how to create a complex POCO which talks to stored procedure or multiple table. Or is it just my imagination?
Thanks,
Found the following link and it has some good information, thought share it with anyone interested.
http://blogs.msdn.com/b/adonet/archive/2009/05/21/poco-in-the-entity-framework-part-1-the-experience.aspx

Resources