entity-framework-6

Entity framework connection with oracle database

送分小仙女□ 提交于 2019-12-01 13:51:45
I am using Entity framework 6.1 version and oracle 11. I am new to entity framework. Can anyone please suggest what are the prerequisites for connecting with oracle. any changes are required in the web.config. In web.config,default it is connecting with sql,how can i change it to use Oracle instead of sql. I have a sample project with EF 6 and oracle 11g which only uses nuget packages : https://github.com/ovidiubuligan/EntityFramework_Oracle_sample The most important parts are App.config and packages.config . If you look in App.config you will see that it will use the connection string :

C# Model User, Friend Requests and Friends with Entity Framework Code First

江枫思渺然 提交于 2019-12-01 13:16:52
I have previously asked a question here on SO about a similar topic but have since taken a different approach. This is my model: public class ApplicationUser : IdentityUser<int, CustomUserLogin, CustomUserRole,CustomUserClaim> { public ApplicationUser() { Friends = new List<Friend>(); } [Required] public string Alias { get; set; } public virtual ICollection<Friend> Friends { get; set; } } public class Friend { public virtual int Id { get; set; } public virtual ApplicationUser RequestedBy { get; set; } public virtual ApplicationUser RequestedTo { get; set; } public DateTime? RequestTime { get;

Entity framework connection with oracle database

独自空忆成欢 提交于 2019-12-01 13:04:25
问题 I am using Entity framework 6.1 version and oracle 11. I am new to entity framework. Can anyone please suggest what are the prerequisites for connecting with oracle. any changes are required in the web.config. In web.config,default it is connecting with sql,how can i change it to use Oracle instead of sql. 回答1: I have a sample project with EF 6 and oracle 11g which only uses nuget packages : https://github.com/ovidiubuligan/EntityFramework_Oracle_sample The most important parts are App.config

IManifestTokenResolver for Database First Model?

坚强是说给别人听的谎言 提交于 2019-12-01 12:53:30
We need an option to set the ProviderManifestToken in code for a Database First Model in order to override the value from the EDMX, which defaults to "2012" for SQL Server 2012 in our particular case. What we've tried so far: As described in this post we decorated our context class with the DbConfigurationType attribute, our derived class looks exactly the same as in that post. internal sealed class MyDbConfiguration : DbConfiguration { public MyDbConfiguration() { //this.AddDependencyResolver(new SingletonDependencyResolver<IManifestTokenResolver>(new ManifestTokenService())); this

Multiple contexts with Entity Framework 6, reference entities across dbcontexts

早过忘川 提交于 2019-12-01 12:23:28
I am writing two MVC5 (with EF6 and code-first) web apps using generic UnitOfWork that gets the dbContext injected by Unity. We are required to have two databases (Main Database and Project Specific DB) and have a reference between the two. Here's an example: in the main context I have an entity Employee in the project context I have an entity Department I need to create Departments in my Project that group and organize Employees from Main. Can I have... ICollection<Employee> Employees { get; set; } in the Project DB's Department Entity ? (the relationship between Employees and Departments is

Conventions for joins in Entity Framework 6.1.0 Code First

元气小坏坏 提交于 2019-12-01 12:15:12
I believe my question is simple (not sure if the answer is as well): Does anybody know how to force Entity Framework to use "INNER JOIN" as default convention, instead of "LEFT OUTER JOIN"? If you want to enforce inner or outer joins explicitly you can always use the Join or GroupJoin methods, respectively. (Or the comprehensive equivalents join and join ... into ). But, generally speaking, in LINQ statements you should avoid using explicit join statements. Use navigation properties instead. Navigation properties are the associations that have been defined between entities. Querying by

Ignoring all properties but some in Entity Framework 6

做~自己de王妃 提交于 2019-12-01 12:05:13
I want to persist some data on a database using Entity Framework. I have some bigger POCOs but I want to store some of the properties only. I know that I can achieve this with the Fluent API by using the Ignore() method. But is there also the possibility of not only ignoring a defined property but all properties but the defined? So if you have a POCO like this: public class MyPoco { public int Id { get; set; } public string Name { get; set; } . . . public int SomeSpecialId { get; set; } } And you only want to store the Id and the SomeSpecialId , you would do: protected override void

C# Model User, Friend Requests and Friends with Entity Framework Code First

放肆的年华 提交于 2019-12-01 11:37:14
问题 I have previously asked a question here on SO about a similar topic but have since taken a different approach. This is my model: public class ApplicationUser : IdentityUser<int, CustomUserLogin, CustomUserRole,CustomUserClaim> { public ApplicationUser() { Friends = new List<Friend>(); } [Required] public string Alias { get; set; } public virtual ICollection<Friend> Friends { get; set; } } public class Friend { public virtual int Id { get; set; } public virtual ApplicationUser RequestedBy {

Ignoring all properties but some in Entity Framework 6

最后都变了- 提交于 2019-12-01 11:37:13
问题 I want to persist some data on a database using Entity Framework. I have some bigger POCOs but I want to store some of the properties only. I know that I can achieve this with the Fluent API by using the Ignore() method. But is there also the possibility of not only ignoring a defined property but all properties but the defined? So if you have a POCO like this: public class MyPoco { public int Id { get; set; } public string Name { get; set; } . . . public int SomeSpecialId { get; set; } } And

Multiple contexts with Entity Framework 6, reference entities across dbcontexts

五迷三道 提交于 2019-12-01 11:12:18
问题 I am writing two MVC5 (with EF6 and code-first) web apps using generic UnitOfWork that gets the dbContext injected by Unity. We are required to have two databases (Main Database and Project Specific DB) and have a reference between the two. Here's an example: in the main context I have an entity Employee in the project context I have an entity Department I need to create Departments in my Project that group and organize Employees from Main. Can I have... ICollection<Employee> Employees { get;