Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

E-F code first database design: Choosing which model classes are part of the database, and which ones are not

$
0
0

When creating model classes in a project that is using code-first with E-F, does E-F only create database entities for classes that you have defined a DbSet for?  For example, if I had the following segment (assuming Picture, Album, and Picture_Album are all data model classes that I've defined as Public classes:

public DbSet<Picture> Pictures { get; set; }
public DbSet<Album> Albums { get; set; }
public List<Picture_Album> Pictures_Albums { get; set; }

E-F would only create tables for the Picture and Album classes, correct?  Since I defined DbSets for those classes, and it would ignore the Picture_album list (which that table would be used internally in memory and not need to be stored in the database as a table, since it's not defined with a DbSet.

I basically need to be able to create "view models" (like you find in MVC) for storing data in memory that does not need to be persisted/written to the database.  I'm also doing this mostly in code, and not using the EDMX designer/wizard (I don't think that matters though).


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>